freealise commited on
Commit
828e1fe
1 Parent(s): 7bd6821

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -349,13 +349,13 @@ def draw_mask(v, d, evt: gr.EventData):
349
  fgdModel = np.zeros((1,65), np.float64)
350
  rect = (x, y, w, h)
351
  mask = cv2.grabCut(rgb, mask, rect, bgdModel, fgdModel, 5, cv2.GC_INIT_WITH_RECT)
352
- newmask = mask[0]
353
- newmask = np.where((newmask==2)|(newmask==0),1,0).astype('uint8')
354
- print(rgb)
355
  print(newmask)
356
  img = cv2.cvtColor(rgb, cv2.COLOR_RGB2RGBA)*newmask[:,:,np.newaxis]
357
 
358
- d["background"] = img
359
  d["composite"] = img
360
 
361
  return gr.ImageEditor(value=d)
 
349
  fgdModel = np.zeros((1,65), np.float64)
350
  rect = (x, y, w, h)
351
  mask = cv2.grabCut(rgb, mask, rect, bgdModel, fgdModel, 5, cv2.GC_INIT_WITH_RECT)
352
+ mask0 = cv2.cvtColor(mask[0], cv2.COLOR_RGB2RGBA)
353
+ newmask = np.where((mask0==2)|(mask0==0),1,0).astype('uint8')
354
+ print(mask0)
355
  print(newmask)
356
  img = cv2.cvtColor(rgb, cv2.COLOR_RGB2RGBA)*newmask[:,:,np.newaxis]
357
 
358
+ d["layers"][0]= mask0
359
  d["composite"] = img
360
 
361
  return gr.ImageEditor(value=d)