Ashoka74 commited on
Commit
a0b057f
Β·
verified Β·
1 Parent(s): 7af5bfa

Update gradio_demo.py

Browse files
Files changed (1) hide show
  1. gradio_demo.py +13 -12
gradio_demo.py CHANGED
@@ -1164,7 +1164,8 @@ with block:
1164
  value=""
1165
  )
1166
  extract_button = gr.Button(value="(Option 2) Remove Background")
1167
- #find_objects_button = gr.Button(value="Find Objects")
 
1168
  extracted_fg = gr.Image(type="numpy", label="Extracted Foreground", height=480)
1169
 
1170
  with gr.Row():
@@ -1310,13 +1311,13 @@ with block:
1310
 
1311
  # # return mask_mover.create_composite(self.original_bg, x_pos, y_pos, scale)
1312
 
1313
- # def update_position(background, x_pos, y_pos, scale):
1314
- # if background is None:
1315
- # return None
1316
- # # Restore a fresh copy of the original background
1317
- # fresh_bg = bg_manager.original_bg.copy()
1318
- # # Composite the foreground once
1319
- # return mask_mover.create_composite(fresh_bg, float(x_pos), float(y_pos), float(scale))
1320
 
1321
 
1322
 
@@ -1337,22 +1338,22 @@ with block:
1337
  inputs=[input_bg],
1338
  outputs=[input_bg],
1339
  show_progress=False
1340
- )
1341
 
1342
  x_slider.change(
1343
- fn=lambda bg, x, y, scale: update_position(bg, x, y, scale),
1344
  inputs=[input_bg, x_slider, y_slider, fg_scale_slider],
1345
  outputs=[input_bg]
1346
  )
1347
 
1348
  y_slider.change(
1349
- fn=lambda bg, x, y, scale: update_position(bg, x, y, scale),
1350
  inputs=[input_bg, x_slider, y_slider, fg_scale_slider],
1351
  outputs=[input_bg]
1352
  )
1353
 
1354
  fg_scale_slider.change(
1355
- fn=lambda bg, x, y, scale: update_position(bg, x, y, scale),
1356
  inputs=[input_bg, x_slider, y_slider, fg_scale_slider],
1357
  outputs=[input_bg]
1358
  )
 
1164
  value=""
1165
  )
1166
  extract_button = gr.Button(value="(Option 2) Remove Background")
1167
+ with gr.Row():
1168
+ extracted_objects = gr.Image(type="numpy", label="Extracted Foreground", height=480)
1169
  extracted_fg = gr.Image(type="numpy", label="Extracted Foreground", height=480)
1170
 
1171
  with gr.Row():
 
1311
 
1312
  # # return mask_mover.create_composite(self.original_bg, x_pos, y_pos, scale)
1313
 
1314
+ def update_position(background, x_pos, y_pos, scale):
1315
+ if background is None:
1316
+ return None
1317
+ # Restore a fresh copy of the original background
1318
+ fresh_bg = bg_manager.original_bg.copy()
1319
+ # Composite the foreground once
1320
+ return mask_mover.create_composite(fresh_bg, float(x_pos), float(y_pos), float(scale))
1321
 
1322
 
1323
 
 
1338
  inputs=[input_bg],
1339
  outputs=[input_bg],
1340
  show_progress=False
1341
+ )
1342
 
1343
  x_slider.change(
1344
+ fn=lambda bg, x, y, scale: bg_manager.update_position(bg, x, y, scale),
1345
  inputs=[input_bg, x_slider, y_slider, fg_scale_slider],
1346
  outputs=[input_bg]
1347
  )
1348
 
1349
  y_slider.change(
1350
+ fn=lambda bg, x, y, scale: bg_manager.update_position(bg, x, y, scale),
1351
  inputs=[input_bg, x_slider, y_slider, fg_scale_slider],
1352
  outputs=[input_bg]
1353
  )
1354
 
1355
  fg_scale_slider.change(
1356
+ fn=lambda bg, x, y, scale: bg_manager.update_position(bg, x, y, scale),
1357
  inputs=[input_bg, x_slider, y_slider, fg_scale_slider],
1358
  outputs=[input_bg]
1359
  )