Spaces:
Sleeping
Sleeping
ahmadarrabi
commited on
Commit
•
5fb0367
1
Parent(s):
57c39e9
sss
Browse files
app.py
CHANGED
@@ -1,8 +1,19 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
def generate_image(image):
|
4 |
if image is not None:
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
iface = gr.Interface(
|
8 |
fn=generate_image,
|
|
|
1 |
import gradio as gr
|
2 |
+
import torch
|
3 |
|
4 |
def generate_image(image):
|
5 |
if image is not None:
|
6 |
+
sketch = image['layers'][0]
|
7 |
+
with torch.no_grad(): # Disable gradient calculation for inference
|
8 |
+
model_output = pipe(prompt, num_inference_steps=20, generator=torch.manual_seed(0), image=sketch)
|
9 |
+
generated_image = model_output.images[0]
|
10 |
+
|
11 |
+
return generated_image
|
12 |
+
|
13 |
+
controlnet_model_name_or_path = "controlnet_path"
|
14 |
+
pretrained_model_name_or_path = "runwayml/stable-diffusion-v1-5"
|
15 |
+
controlnet = ControlNetModel.from_pretrained(controlnet_model_name_or_path, torch_dtype=torch.float16, conditioning_channels=3)
|
16 |
+
pipe = StableDiffusionControlNetPipeline.from_pretrained(pretrained_model_name_or_path, controlnet=controlnet, torch_dtype=torch.float16, safety_checker=None)
|
17 |
|
18 |
iface = gr.Interface(
|
19 |
fn=generate_image,
|