nuwandaa commited on
Commit
4893621
·
verified ·
1 Parent(s): 9c7406f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -147,23 +147,23 @@ def inpaint(image, width, height, overlap_percentage, num_inference_steps, resiz
147
  # mask_blur = mask.filter(ImageFilter.GaussianBlur(10))
148
  # cnet_image = Image.composite(result, cnet_image, mask)
149
  size = 10; # how many pixel extension do you want to dilate
150
- number = 1; # numbering purpose
151
- trimap_mask = trimap(image, name, size, number, erosion=False)
152
 
153
  # estimate alpha from image and trimap
154
- alpha = estimate_alpha_cf(cnet_image, trimap_mask)
155
 
156
  # make gray background
157
  background = result
158
 
159
  # estimate foreground from image and alpha
160
- foreground = estimate_foreground_ml(cnet_image, alpha)
161
 
162
  # blend foreground with background and alpha, less color bleeding
163
- new_image = blend(foreground, background, alpha)
164
  # cnet_image.paste(result, (0, 0), mask)
165
 
166
- return new_image, background
167
 
168
  def preview_image_and_mask(image, width, height, overlap_percentage, resize_option, custom_resize_percentage, alignment, overlap_left, overlap_right, overlap_top, overlap_bottom):
169
  background, mask = prepare_image_and_mask(image, width, height, overlap_percentage, resize_option, custom_resize_percentage, alignment, overlap_left, overlap_right, overlap_top, overlap_bottom)
 
147
  # mask_blur = mask.filter(ImageFilter.GaussianBlur(10))
148
  # cnet_image = Image.composite(result, cnet_image, mask)
149
  size = 10; # how many pixel extension do you want to dilate
150
+ number = 1; # numbering purpose
151
+ trimap_mask = trimap(np.array(mask), name, size, number, erosion=False)
152
 
153
  # estimate alpha from image and trimap
154
+ alpha = estimate_alpha_cf(np.array(cnet_image), trimap_mask)
155
 
156
  # make gray background
157
  background = result
158
 
159
  # estimate foreground from image and alpha
160
+ foreground = estimate_foreground_ml(np.array(cnet_image), alpha)
161
 
162
  # blend foreground with background and alpha, less color bleeding
163
+ new_image = blend(foreground, np.array(background), alpha)
164
  # cnet_image.paste(result, (0, 0), mask)
165
 
166
+ return Image.fromarray(new_image), background
167
 
168
  def preview_image_and_mask(image, width, height, overlap_percentage, resize_option, custom_resize_percentage, alignment, overlap_left, overlap_right, overlap_top, overlap_bottom):
169
  background, mask = prepare_image_and_mask(image, width, height, overlap_percentage, resize_option, custom_resize_percentage, alignment, overlap_left, overlap_right, overlap_top, overlap_bottom)