freealise commited on
Commit
29290cf
·
verified ·
1 Parent(s): 1464def

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -615,10 +615,10 @@ def draw_mask(l, t, b, v, d, evt: gr.EventData):
615
  d["layers"][0][sel==0] = (0,0,0,0)
616
 
617
 
618
- mask = cv2.cvtColor(d["layers"][0], cv2.COLOR_RGBA2GRAY) - 128
619
- mask[mask<0] = 0
620
- print(mask[mask>0])
621
- mask, bgdModel, fgdModel = cv2.grabCut(cv2.cvtColor(d["background"], cv2.COLOR_RGBA2RGB), mask, None,None,None,15, cv2.GC_INIT_WITH_MASK)
622
  mask = np.where((mask==2)|(mask==0),1,0).astype('uint8')
623
 
624
  frame = cv2.imread(frames[frame_selected], cv2.IMREAD_UNCHANGED).astype(np.uint8)
 
615
  d["layers"][0][sel==0] = (0,0,0,0)
616
 
617
 
618
+ mask = cv2.cvtColor(d["layers"][0], cv2.COLOR_RGBA2GRAY)
619
+ mask[mask==0] = 128
620
+ print(mask[mask>0]-128)
621
+ mask, bgdModel, fgdModel = cv2.grabCut(cv2.cvtColor(d["background"], cv2.COLOR_RGBA2RGB), mask-128, None,None,None,15, cv2.GC_INIT_WITH_MASK)
622
  mask = np.where((mask==2)|(mask==0),1,0).astype('uint8')
623
 
624
  frame = cv2.imread(frames[frame_selected], cv2.IMREAD_UNCHANGED).astype(np.uint8)