Update app.py
Browse files
app.py
CHANGED
|
@@ -213,9 +213,14 @@ def run(
|
|
| 213 |
use_canny: bool = False,
|
| 214 |
progress=gr.Progress(track_tqdm=True),
|
| 215 |
) -> PIL.Image.Image:
|
| 216 |
-
width, height
|
| 217 |
-
|
| 218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
image = image['composite'].resize((new_width, new_height))
|
| 220 |
|
| 221 |
if use_canny:
|
|
@@ -256,7 +261,7 @@ def run(
|
|
| 256 |
height=new_height,
|
| 257 |
).images[0]
|
| 258 |
else:
|
| 259 |
-
|
| 260 |
prompt=prompt,
|
| 261 |
negative_prompt=negative_prompt,
|
| 262 |
image=image,
|
|
@@ -265,7 +270,8 @@ def run(
|
|
| 265 |
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
| 266 |
guidance_scale=guidance_scale,
|
| 267 |
width=new_width,
|
| 268 |
-
height=new_height,
|
|
|
|
| 269 |
|
| 270 |
return (controlnet_img, out)
|
| 271 |
|
|
|
|
| 213 |
use_canny: bool = False,
|
| 214 |
progress=gr.Progress(track_tqdm=True),
|
| 215 |
) -> PIL.Image.Image:
|
| 216 |
+
width, height = image['composite'].size
|
| 217 |
+
|
| 218 |
+
# Calculate new dimensions while maintaining aspect ratio
|
| 219 |
+
max_size = 1024
|
| 220 |
+
ratio = min(max_size / width, max_size / height)
|
| 221 |
+
new_width = int(width * ratio)
|
| 222 |
+
new_height = int(height * ratio)
|
| 223 |
+
|
| 224 |
image = image['composite'].resize((new_width, new_height))
|
| 225 |
|
| 226 |
if use_canny:
|
|
|
|
| 261 |
height=new_height,
|
| 262 |
).images[0]
|
| 263 |
else:
|
| 264 |
+
out = pipe(
|
| 265 |
prompt=prompt,
|
| 266 |
negative_prompt=negative_prompt,
|
| 267 |
image=image,
|
|
|
|
| 270 |
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
| 271 |
guidance_scale=guidance_scale,
|
| 272 |
width=new_width,
|
| 273 |
+
height=new_height,
|
| 274 |
+
).images[0]
|
| 275 |
|
| 276 |
return (controlnet_img, out)
|
| 277 |
|