freealise commited on
Commit
5c437d9
1 Parent(s): a3a4804

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -346,6 +346,7 @@ def draw_mask(v, d, evt: gr.EventData):
346
  bgdModel = np.zeros((1,65),np.float64)
347
  fgdModel = np.zeros((1,65),np.float64)
348
 
 
349
  mask[newmask == 0] = 0
350
  mask[newmask == 255] = 1
351
  mask, bgdModel, fgdModel = cv2.grabCut(img,mask,None,bgdModel,fgdModel,5,cv2.GC_INIT_WITH_MASK)
@@ -355,7 +356,7 @@ def draw_mask(v, d, evt: gr.EventData):
355
  d["layers"][0] = 255-img
356
  d["composite"][0] = 255-img
357
 
358
- return d
359
 
360
 
361
  css = """
@@ -406,7 +407,7 @@ with gr.Blocks(css=css) as demo:
406
  output_frame = gr.Gallery(label="Frames", preview=True, columns=8192, type="numpy")
407
  output_switch = gr.Checkbox(label="Show depths")
408
  output_switch.input(fn=switch_rows, inputs=[output_switch], outputs=[output_frame])
409
- output_mask = gr.ImageEditor(layers=True, sources=None, type="numpy", interactive=True, transforms=(None,), eraser=gr.Eraser(), brush=gr.Brush(default_size=0, colors=['black', 'darkgray', 'gray', 'lightgray', 'white']), elem_id="image_edit")
410
  submit = gr.Button("Submit")
411
  with gr.Column():
412
  model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl")], type="value", value="vits", label='Model Type')
 
346
  bgdModel = np.zeros((1,65),np.float64)
347
  fgdModel = np.zeros((1,65),np.float64)
348
 
349
+ mask = []
350
  mask[newmask == 0] = 0
351
  mask[newmask == 255] = 1
352
  mask, bgdModel, fgdModel = cv2.grabCut(img,mask,None,bgdModel,fgdModel,5,cv2.GC_INIT_WITH_MASK)
 
356
  d["layers"][0] = 255-img
357
  d["composite"][0] = 255-img
358
 
359
+ return gr.ImageEditor(value=d)
360
 
361
 
362
  css = """
 
407
  output_frame = gr.Gallery(label="Frames", preview=True, columns=8192, type="numpy")
408
  output_switch = gr.Checkbox(label="Show depths")
409
  output_switch.input(fn=switch_rows, inputs=[output_switch], outputs=[output_frame])
410
+ output_mask = gr.ImageEditor(layers=True, sources=None, type="numpy", interactive=True, transforms=(None,), eraser=gr.Eraser(), brush=gr.Brush(default_size=0, colors=['black', '#505050', '#a0a0a0', 'white']), elem_id="image_edit")
411
  submit = gr.Button("Submit")
412
  with gr.Column():
413
  model_type = gr.Dropdown([("small", "vits"), ("base", "vitb"), ("large", "vitl")], type="value", value="vits", label='Model Type')