Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
@@ -179,7 +179,6 @@ def segment_and_overlay(image: Image.Image, points):
|
|
179 |
overlaid = apply_mask_overlay(image, mask)
|
180 |
return overlaid
|
181 |
|
182 |
-
|
183 |
def reset_points():
|
184 |
"""
|
185 |
清空 prompt 点
|
@@ -355,9 +354,9 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
|
|
355 |
points_state = gr.State([])
|
356 |
points_output = gr.Textbox(label="Target Object Prompts", interactive=False)
|
357 |
# 为 image_annotation 添加点击事件记录 prompt 点
|
358 |
-
image_annotation.
|
359 |
record_click,
|
360 |
-
inputs=[
|
361 |
outputs=[points_state, points_output]
|
362 |
)
|
363 |
# 新增:分割后展示结果的组件
|
@@ -489,7 +488,7 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
|
|
489 |
|
490 |
# Launch the Gradio app
|
491 |
if __name__ == "__main__":
|
492 |
-
sam_checkpoint = hf_hub_download(
|
493 |
model_type = "vit_h"
|
494 |
sam = sam_model_registry[model_type](checkpoint=sam_checkpoint)
|
495 |
sam.cuda()
|
|
|
179 |
overlaid = apply_mask_overlay(image, mask)
|
180 |
return overlaid
|
181 |
|
|
|
182 |
def reset_points():
|
183 |
"""
|
184 |
清空 prompt 点
|
|
|
354 |
points_state = gr.State([])
|
355 |
points_output = gr.Textbox(label="Target Object Prompts", interactive=False)
|
356 |
# 为 image_annotation 添加点击事件记录 prompt 点
|
357 |
+
image_annotation.select(
|
358 |
record_click,
|
359 |
+
inputs=[points_state],
|
360 |
outputs=[points_state, points_output]
|
361 |
)
|
362 |
# 新增:分割后展示结果的组件
|
|
|
488 |
|
489 |
# Launch the Gradio app
|
490 |
if __name__ == "__main__":
|
491 |
+
sam_checkpoint = hf_hub_download("ybelkada/segment-anything", "checkpoints/sam_vit_h_4b8939.pth")
|
492 |
model_type = "vit_h"
|
493 |
sam = sam_model_registry[model_type](checkpoint=sam_checkpoint)
|
494 |
sam.cuda()
|