Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -404,9 +404,10 @@ def draw_mask(f, l, c, k, v, d, evt: gr.EventData):
|
|
404 |
params["l"] = l
|
405 |
params["c"] = c
|
406 |
params["k"] = k
|
|
|
|
|
407 |
else:
|
408 |
-
|
409 |
-
mask = cv2.inRange(bg, 250, 255)
|
410 |
|
411 |
x = points[len(points)-1][0]
|
412 |
y = points[len(points)-1][1]
|
@@ -423,7 +424,6 @@ def draw_mask(f, l, c, k, v, d, evt: gr.EventData):
|
|
423 |
grad = cv2.addWeighted(grad_x, 0.5, grad_y, 0.5, 0)
|
424 |
mask[cv2.inRange(grad, 1, 255)>0] = 1
|
425 |
|
426 |
-
d["layers"][0] = cv2.cvtColor(bg, cv2.COLOR_GRAY2RGBA)
|
427 |
d["layers"][1][mask>0] = (0,0,0,255)
|
428 |
|
429 |
return gr.ImageEditor(value=d)
|
|
|
404 |
params["l"] = l
|
405 |
params["c"] = c
|
406 |
params["k"] = k
|
407 |
+
|
408 |
+
d["layers"][0] = cv2.cvtColor(bg, cv2.COLOR_GRAY2RGBA)
|
409 |
else:
|
410 |
+
mask = cv2.cvtColor(d["layers"][0], cv2.COLOR_RGBA2GRAY)
|
|
|
411 |
|
412 |
x = points[len(points)-1][0]
|
413 |
y = points[len(points)-1][1]
|
|
|
424 |
grad = cv2.addWeighted(grad_x, 0.5, grad_y, 0.5, 0)
|
425 |
mask[cv2.inRange(grad, 1, 255)>0] = 1
|
426 |
|
|
|
427 |
d["layers"][1][mask>0] = (0,0,0,255)
|
428 |
|
429 |
return gr.ImageEditor(value=d)
|