Deadmon commited on
Commit
c72212d
1 Parent(s): 3b101cf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -11
app.py CHANGED
@@ -213,14 +213,9 @@ def run(
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,7 +256,7 @@ def run(
261
  height=new_height,
262
  ).images[0]
263
  else:
264
- out = pipe(
265
  prompt=prompt,
266
  negative_prompt=negative_prompt,
267
  image=image,
@@ -270,8 +265,7 @@ def run(
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
 
 
213
  use_canny: bool = False,
214
  progress=gr.Progress(track_tqdm=True),
215
  ) -> PIL.Image.Image:
216
+ width, height = image['composite'].size
217
+ ratio = np.sqrt(1024. * 1024. / (width * height))
218
+ new_width, new_height = int(width * ratio), int(height * ratio)
 
 
 
 
 
219
  image = image['composite'].resize((new_width, new_height))
220
 
221
  if use_canny:
 
256
  height=new_height,
257
  ).images[0]
258
  else:
259
+ out = pipe(
260
  prompt=prompt,
261
  negative_prompt=negative_prompt,
262
  image=image,
 
265
  controlnet_conditioning_scale=controlnet_conditioning_scale,
266
  guidance_scale=guidance_scale,
267
  width=new_width,
268
+ height=new_height,).images[0]
 
269
 
270
  return (controlnet_img, out)
271