Update app.py
Browse files
app.py
CHANGED
@@ -400,6 +400,9 @@ def blur_image(image, depth, blur_data):
|
|
400 |
blur_frame[blur_mask>0] = blur[blur_mask>0]
|
401 |
j = j + 1
|
402 |
|
|
|
|
|
|
|
403 |
return blur_frame
|
404 |
|
405 |
def loadfile(f):
|
@@ -617,12 +620,12 @@ def draw_mask(l, t, b, v, d, evt: gr.EventData):
|
|
617 |
|
618 |
mask = cv2.cvtColor(d["layers"][0], cv2.COLOR_RGBA2GRAY)
|
619 |
mask[mask==0] = 128
|
620 |
-
print(mask[mask>
|
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
|
623 |
|
624 |
frame = cv2.imread(frames[frame_selected], cv2.IMREAD_UNCHANGED).astype(np.uint8)
|
625 |
-
frame[
|
626 |
cv2.imwrite(frames[frame_selected], frame)
|
627 |
|
628 |
return gr.ImageEditor(value=d)
|
|
|
400 |
blur_frame[blur_mask>0] = blur[blur_mask>0]
|
401 |
j = j + 1
|
402 |
|
403 |
+
white = cv2.inRange(blur_frame, np.array([255,255,255]), np.array([255,255,255]))
|
404 |
+
blur_frame[white>0] = (254,254,254)
|
405 |
+
|
406 |
return blur_frame
|
407 |
|
408 |
def loadfile(f):
|
|
|
620 |
|
621 |
mask = cv2.cvtColor(d["layers"][0], cv2.COLOR_RGBA2GRAY)
|
622 |
mask[mask==0] = 128
|
623 |
+
print(mask[mask>128]-128)
|
624 |
mask, bgdModel, fgdModel = cv2.grabCut(cv2.cvtColor(d["background"], cv2.COLOR_RGBA2RGB), mask-128, None,None,None,15, cv2.GC_INIT_WITH_MASK)
|
625 |
+
mask = np.where((mask==2)|(mask==0),0,1).astype('uint8')
|
626 |
|
627 |
frame = cv2.imread(frames[frame_selected], cv2.IMREAD_UNCHANGED).astype(np.uint8)
|
628 |
+
frame[mask>0] = (255,255,255)
|
629 |
cv2.imwrite(frames[frame_selected], frame)
|
630 |
|
631 |
return gr.ImageEditor(value=d)
|