vilarin commited on
Commit
6ab5cc8
·
verified ·
1 Parent(s): 1b84faf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -49,6 +49,13 @@ def inpaintGen(
49
 
50
  width, height = source_img.size
51
 
 
 
 
 
 
 
 
52
  if randomize_seed:
53
  seed = random.randint(0, MAX_SEED)
54
  generator = torch.Generator("cpu").manual_seed(seed)
@@ -57,8 +64,8 @@ def inpaintGen(
57
  prompt=inpaint_prompt,
58
  image=source_img,
59
  mask_image=binary_mask,
60
- width=width,
61
- height=height,
62
  num_inference_steps=num_steps,
63
  generator=generator,
64
  guidance_scale=guidance,
 
49
 
50
  width, height = source_img.size
51
 
52
+ new_width = (width // 16) * 16
53
+ new_height = (height // 16) * 16
54
+
55
+ # If the image size is not already divisible by 16, resize it
56
+ if width != new_width or height != new_height:
57
+ source_img = source_img.resize((new_width, new_height), Image.LANCZOS)
58
+
59
  if randomize_seed:
60
  seed = random.randint(0, MAX_SEED)
61
  generator = torch.Generator("cpu").manual_seed(seed)
 
64
  prompt=inpaint_prompt,
65
  image=source_img,
66
  mask_image=binary_mask,
67
+ width=new_width,
68
+ height=new_height,
69
  num_inference_steps=num_steps,
70
  generator=generator,
71
  guidance_scale=guidance,