Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -228,6 +228,10 @@ def initialize_models(sam_path, adapter_pth, model_cfg, cfg):
|
|
228 |
mask_adapter.load_state_dict(adapter_state_dict)
|
229 |
print("Mask Adapter model initialized.")
|
230 |
|
|
|
|
|
|
|
|
|
231 |
def clear_everything(img_state):
|
232 |
img_state.clear()
|
233 |
return img_state, None, None
|
@@ -346,9 +350,12 @@ with gr.Blocks() as demo:
|
|
346 |
|
347 |
gr.Examples(
|
348 |
examples=examples_point,
|
349 |
-
inputs=input_image,
|
350 |
-
outputs=output_image_box,
|
351 |
examples_per_page=5,
|
|
|
|
|
|
|
352 |
)
|
353 |
|
354 |
with gr.TabItem("Point Mode"):
|
@@ -393,9 +400,16 @@ with gr.Blocks() as demo:
|
|
393 |
def clear_and_set_example_point(example):
|
394 |
clear_everything(img_state_points)
|
395 |
return example
|
396 |
-
|
397 |
-
|
398 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
399 |
|
400 |
|
401 |
|
|
|
228 |
mask_adapter.load_state_dict(adapter_state_dict)
|
229 |
print("Mask Adapter model initialized.")
|
230 |
|
231 |
+
def preprocess_example(input_img, img_state):
|
232 |
+
img_state.clear()
|
233 |
+
return img_state,None
|
234 |
+
|
235 |
def clear_everything(img_state):
|
236 |
img_state.clear()
|
237 |
return img_state, None, None
|
|
|
350 |
|
351 |
gr.Examples(
|
352 |
examples=examples_point,
|
353 |
+
inputs=[input_image, img_state_bbox],
|
354 |
+
outputs=[img_state_bbox, output_image_box],
|
355 |
examples_per_page=5,
|
356 |
+
fn=preprocess_example,
|
357 |
+
run_on_click=True,
|
358 |
+
cache_examples=False,
|
359 |
)
|
360 |
|
361 |
with gr.TabItem("Point Mode"):
|
|
|
400 |
def clear_and_set_example_point(example):
|
401 |
clear_everything(img_state_points)
|
402 |
return example
|
403 |
+
|
404 |
+
gr.Examples(
|
405 |
+
examples=examples_point,
|
406 |
+
inputs=[input_image, img_state_points],
|
407 |
+
outputs=[img_state_points, output_image_point],
|
408 |
+
examples_per_page=5,
|
409 |
+
fn=preprocess_example,
|
410 |
+
run_on_click=True,
|
411 |
+
cache_examples=False,
|
412 |
+
)
|
413 |
|
414 |
|
415 |
|