Spaces:
Running
on
Zero
Running
on
Zero
florence edge case
Browse files
app.py
CHANGED
@@ -83,7 +83,14 @@ def run_florence(image, text_input):
|
|
83 |
task=task_prompt,
|
84 |
image_size=(image.width, image.height)
|
85 |
)
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
def remove_directory_contents(directory):
|
89 |
for root, dirs, files in os.walk(directory, topdown=False):
|
@@ -227,7 +234,7 @@ demo = gr.Interface(
|
|
227 |
This demo uses [Florence-2](https://huggingface.co/microsoft/Florence-2-large), to enable text-prompted object detection for [SAM2](https://github.com/facebookresearch/segment-anything).
|
228 |
|
229 |
1. Upload a short video (< 10 sec , you can fork this space on larger GPU for longer vids)
|
230 |
-
2. Describe the object to segment.
|
231 |
3. Get your segmented video.
|
232 |
"""
|
233 |
)
|
|
|
83 |
task=task_prompt,
|
84 |
image_size=(image.width, image.height)
|
85 |
)
|
86 |
+
|
87 |
+
bboxes = parsed_answer[task_prompt]['bboxes']
|
88 |
+
if not bboxes:
|
89 |
+
print(f"No objects detected for prompt: '{text_input}'. Trying with a default bounding box.")
|
90 |
+
# Return a default bounding box covering the entire image
|
91 |
+
return [0, 0, image.width, image.height]
|
92 |
+
|
93 |
+
return bboxes[0]
|
94 |
|
95 |
def remove_directory_contents(directory):
|
96 |
for root, dirs, files in os.walk(directory, topdown=False):
|
|
|
234 |
This demo uses [Florence-2](https://huggingface.co/microsoft/Florence-2-large), to enable text-prompted object detection for [SAM2](https://github.com/facebookresearch/segment-anything).
|
235 |
|
236 |
1. Upload a short video (< 10 sec , you can fork this space on larger GPU for longer vids)
|
237 |
+
2. Describe the object to segment (The object should be visible in the first frame).
|
238 |
3. Get your segmented video.
|
239 |
"""
|
240 |
)
|