Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -89,17 +89,17 @@ def generate(
|
|
89 |
mask_image = load_image(mask_url)
|
90 |
|
91 |
if use_controlnet:
|
92 |
-
image = load_image(img_url)
|
93 |
-
image = np.array(image)
|
94 |
-
|
95 |
-
# get canny image
|
96 |
-
image = cv2.Canny(image, 100, 200)
|
97 |
-
image = image[:, :, None]
|
98 |
-
image = np.concatenate([image, image, image], axis=2)
|
99 |
-
canny_image = Image.fromarray(image)
|
100 |
-
|
101 |
controlnet = ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-canny", torch_dtype=torch.float16)
|
102 |
pipe = StableDiffusionControlNetPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float16)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
if use_lora:
|
105 |
pipe.load_lora_weights(lora)
|
@@ -124,20 +124,13 @@ def generate(
|
|
124 |
negative_prompt_2 = None # type: ignore
|
125 |
|
126 |
if use_controlnet:
|
127 |
-
|
128 |
-
|
|
|
|
|
129 |
image=image,
|
130 |
control_image=canny_image,
|
131 |
-
negative_prompt=negative_prompt,
|
132 |
-
prompt_2=prompt_2,
|
133 |
-
width=width,
|
134 |
-
height=height,
|
135 |
-
negative_prompt_2=negative_prompt_2,
|
136 |
-
guidance_scale=guidance_scale_base,
|
137 |
-
num_inference_steps=num_inference_steps_base,
|
138 |
-
generator=generator,
|
139 |
).images[0]
|
140 |
-
return images
|
141 |
|
142 |
with gr.Blocks(theme=gr.themes.Soft(), css="style.css") as demo:
|
143 |
gr.HTML(
|
|
|
89 |
mask_image = load_image(mask_url)
|
90 |
|
91 |
if use_controlnet:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
controlnet = ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-canny", torch_dtype=torch.float16)
|
93 |
pipe = StableDiffusionControlNetPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float16)
|
94 |
+
|
95 |
+
image = load_image("https://hf.co/datasets/huggingface/documentation-images/resolve/main/diffusers/input_image_vermeer.png")
|
96 |
+
np_image = np.array(image)
|
97 |
+
|
98 |
+
# get canny image
|
99 |
+
np_image = cv2.Canny(np_image, 100, 200)
|
100 |
+
np_image = np_image[:, :, None]
|
101 |
+
np_image = np.concatenate([np_image, np_image, np_image], axis=2)
|
102 |
+
canny_image = Image.fromarray(np_image)
|
103 |
|
104 |
if use_lora:
|
105 |
pipe.load_lora_weights(lora)
|
|
|
124 |
negative_prompt_2 = None # type: ignore
|
125 |
|
126 |
if use_controlnet:
|
127 |
+
image = pipe(
|
128 |
+
"futuristic-looking woman",
|
129 |
+
num_inference_steps=20,
|
130 |
+
generator=generator,
|
131 |
image=image,
|
132 |
control_image=canny_image,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
).images[0]
|
|
|
134 |
|
135 |
with gr.Blocks(theme=gr.themes.Soft(), css="style.css") as demo:
|
136 |
gr.HTML(
|