basso4 commited on
Commit
2c997cd
Β·
verified Β·
1 Parent(s): bcc6112

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -178,19 +178,21 @@ if __name__ == "__main__":
178
  #apply seamlessClone technique here
179
  #img_base
180
  dict = dict['background'].convert("RGB").resize((384, 512))
181
- dict = np.array(dict)
182
  dict = cv2.cvtColor(dict, cv2.COLOR_RGB2BGR)
183
 
184
  #img_output
185
  img_cv = rearrange(x_checked_image_torch[0], 'c h w -> h w c').cpu().numpy()
186
- img_cv = (img_cv * 255)
187
  img_cv = cv2.cvtColor(img_cv, cv2.COLOR_RGB2BGR)
188
 
189
  #mask
190
  mask_cv = mask_cv.convert("L").resize((384,512))
191
  mask_cv = np.array(mask_cv)
192
  mask_cv = 255-mask_cv
193
-
 
 
194
 
195
  img_C = cv2.seamlessClone(dict, img_cv, mask_cv, (192, 256), cv2.NORMAL_CLONE)
196
  img_C = cv2.cvtColor(img_C, cv2.COLOR_BGR2RGB)
 
178
  #apply seamlessClone technique here
179
  #img_base
180
  dict = dict['background'].convert("RGB").resize((384, 512))
181
+ dict = np.array(dict).astype(np.uint8)
182
  dict = cv2.cvtColor(dict, cv2.COLOR_RGB2BGR)
183
 
184
  #img_output
185
  img_cv = rearrange(x_checked_image_torch[0], 'c h w -> h w c').cpu().numpy()
186
+ img_cv = (img_cv * 255).astype(np.uint8)
187
  img_cv = cv2.cvtColor(img_cv, cv2.COLOR_RGB2BGR)
188
 
189
  #mask
190
  mask_cv = mask_cv.convert("L").resize((384,512))
191
  mask_cv = np.array(mask_cv)
192
  mask_cv = 255-mask_cv
193
+
194
+ #Normalize mask to binary values
195
+ _, mask_cv = cv2.threshold(mask_cv, 128, 255, cv2.THRESH_BINARY)
196
 
197
  img_C = cv2.seamlessClone(dict, img_cv, mask_cv, (192, 256), cv2.NORMAL_CLONE)
198
  img_C = cv2.cvtColor(img_C, cv2.COLOR_BGR2RGB)