Spaces:
Running
on
Zero
Running
on
Zero
UPD: added documentation for Image Segmentation and Auto Segmentation
Browse files- SegmentAnything2AssistApp.py +56 -13
SegmentAnything2AssistApp.py
CHANGED
@@ -319,7 +319,12 @@ def __generate_auto_mask(
|
|
319 |
|
320 |
|
321 |
with gradio.Blocks() as base_app:
|
322 |
-
gradio.Markdown(
|
|
|
|
|
|
|
|
|
|
|
323 |
with gradio.Row():
|
324 |
with gradio.Column():
|
325 |
base_model_choice = gradio.Dropdown(
|
@@ -350,19 +355,27 @@ with gradio.Blocks() as base_app:
|
|
350 |
with gradio.Accordion("Image Annotation Documentation", open=False):
|
351 |
gradio.Markdown(
|
352 |
"""
|
|
|
|
|
353 |
Image annotation allows you to mark specific regions of an image with labels.
|
354 |
-
In this app, you can annotate an image by drawing boxes and
|
355 |
The labels can be either '+' or '-'.
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
366 |
)
|
367 |
image_input = gradio_image_annotation.image_annotator(
|
368 |
example_image_annotation
|
@@ -440,7 +453,37 @@ with gradio.Blocks() as base_app:
|
|
440 |
with gradio.Accordion("Auto Annotation Documentation", open=False):
|
441 |
gradio.Markdown(
|
442 |
"""
|
443 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
444 |
)
|
445 |
auto_input = gradio.Image("assets/cars.jpg")
|
446 |
with gradio.Accordion("Advanced Options", open=False):
|
|
|
319 |
|
320 |
|
321 |
with gradio.Blocks() as base_app:
|
322 |
+
gradio.Markdown(
|
323 |
+
"""
|
324 |
+
<h1 style="text-align: center;">Segment Anything 2 Assist π</h1>
|
325 |
+
<p style="text-align: center;">A tool for advanced image segmentation and annotation. πΌοΈβοΈ</p>
|
326 |
+
"""
|
327 |
+
)
|
328 |
with gradio.Row():
|
329 |
with gradio.Column():
|
330 |
base_model_choice = gradio.Dropdown(
|
|
|
355 |
with gradio.Accordion("Image Annotation Documentation", open=False):
|
356 |
gradio.Markdown(
|
357 |
"""
|
358 |
+
### πΌοΈ Image Annotation Documentation
|
359 |
+
|
360 |
Image annotation allows you to mark specific regions of an image with labels.
|
361 |
+
In this app, you can annotate an image by drawing bounding boxes and/or making points on the image.
|
362 |
The labels can be either '+' or '-'.
|
363 |
+
|
364 |
+
**π How to Annotate an Image:**
|
365 |
+
- Bounding Box: Click and drag to draw a box around the desired region.
|
366 |
+
- Positive or Negative Points: Draw a small box (note that the center point will be used for the annotation) and add either "+" or "-" as the label respectively.
|
367 |
+
|
368 |
+
**π¨ Generating Masks:**
|
369 |
+
- Once you have annotated the image, click the 'Generate Mask' button to generate a mask based on the annotations.
|
370 |
+
- The mask can be either a binary mask or a segmented mask, depending on the selected output mode.
|
371 |
+
- You can switch between the output modes using the radio buttons.
|
372 |
+
- If you make any changes to the annotations or the output mode, you need to regenerate the mask by clicking the button again.
|
373 |
+
|
374 |
+
**βοΈ Advanced Options:**
|
375 |
+
- The advanced options allow you to adjust the SAM mask threshold, maximum hole area, and maximum sprinkle area.
|
376 |
+
- These options control the sensitivity and accuracy of the segmentation process.
|
377 |
+
- Experiment with different settings to achieve the desired results.
|
378 |
+
"""
|
379 |
)
|
380 |
image_input = gradio_image_annotation.image_annotator(
|
381 |
example_image_annotation
|
|
|
453 |
with gradio.Accordion("Auto Annotation Documentation", open=False):
|
454 |
gradio.Markdown(
|
455 |
"""
|
456 |
+
### πΌοΈ Auto Annotation Documentation
|
457 |
+
|
458 |
+
Auto annotation allows you to automatically generate masks for an image based on advanced parameters.
|
459 |
+
In this app, you can configure various settings to control the mask generation process.
|
460 |
+
|
461 |
+
**π How to Use Auto Annotation:**
|
462 |
+
- Upload or select an image.
|
463 |
+
- Adjust the advanced options to fine-tune the mask generation process.
|
464 |
+
- Click the 'Generate Auto Mask' button to generate masks automatically.
|
465 |
+
|
466 |
+
**βοΈ Advanced Options:**
|
467 |
+
- **Points Per Side:** Number of points to sample per side of the image.
|
468 |
+
- **Points Per Batch:** Number of points to process in each batch.
|
469 |
+
- **Pred IOU Threshold:** Threshold for the predicted Intersection over Union (IOU) score.
|
470 |
+
- **Stability Score Threshold:** Threshold for the stability score.
|
471 |
+
- **Stability Score Offset:** Offset for the stability score.
|
472 |
+
- **Mask Threshold:** Threshold for the mask generation.
|
473 |
+
- **Box NMS Threshold:** Non-Maximum Suppression (NMS) threshold for boxes.
|
474 |
+
- **Crop N Layers:** Number of layers to crop.
|
475 |
+
- **Crop NMS Threshold:** NMS threshold for crops.
|
476 |
+
- **Crop Overlay Ratio:** Overlay ratio for crops.
|
477 |
+
- **Crop N Points Downscale Factor:** Downscale factor for the number of points in crops.
|
478 |
+
- **Min Mask Region Area:** Minimum area for mask regions.
|
479 |
+
- **Use M2M:** Whether to use M2M (Mask-to-Mask) refinement.
|
480 |
+
- **Multi Mask Output:** Whether to generate multiple masks.
|
481 |
+
|
482 |
+
**π¨ Generating Masks:**
|
483 |
+
- Once you have configured the advanced options, click the 'Generate Auto Mask' button.
|
484 |
+
- The masks will be generated automatically based on the selected parameters.
|
485 |
+
- You can view the generated masks and adjust the settings if needed.
|
486 |
+
"""
|
487 |
)
|
488 |
auto_input = gradio.Image("assets/cars.jpg")
|
489 |
with gradio.Accordion("Advanced Options", open=False):
|