Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kadirnar/segment-anything-video
MetaSeg: Packaged version of the Segment Anything repository
https://github.com/kadirnar/segment-anything-video
object-detection object-segmentation segment-anything segmentation yolov5 yolov6 yolov7 yolov8
Last synced: 6 days ago
JSON representation
MetaSeg: Packaged version of the Segment Anything repository
- Host: GitHub
- URL: https://github.com/kadirnar/segment-anything-video
- Owner: kadirnar
- License: apache-2.0
- Created: 2023-04-06T14:14:59.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-25T22:28:53.000Z (17 days ago)
- Last Synced: 2024-11-29T14:02:53.822Z (13 days ago)
- Topics: object-detection, object-segmentation, segment-anything, segmentation, yolov5, yolov6, yolov7, yolov8
- Language: Python
- Homepage:
- Size: 867 KB
- Stars: 958
- Watchers: 12
- Forks: 67
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- Awesome-Segment-Anything - [**MetaSeg: Packaged version of the Segment Anything repository** - anything model. (Application / Image Detection/Segmentation)
README
This repo is a packaged version of the [segment-anything](https://github.com/facebookresearch/segment-anything) model.
### Installation
```bash
pip install metaseg
```### Usage
```python
from metaseg import SegAutoMaskPredictor, SegManualMaskPredictor# If gpu memory is not enough, reduce the points_per_side and points_per_batch.
# For image
results = SegAutoMaskPredictor().image_predict(
source="image.jpg",
model_type="vit_l", # vit_l, vit_h, vit_b
points_per_side=16,
points_per_batch=64,
min_area=0,
output_path="output.jpg",
show=True,
save=False,
)# For video
results = SegAutoMaskPredictor().video_predict(
source="video.mp4",
model_type="vit_l", # vit_l, vit_h, vit_b
points_per_side=16,
points_per_batch=64,
min_area=1000,
output_path="output.mp4",
)# For manuel box and point selection
# For image
results = SegManualMaskPredictor().image_predict(
source="image.jpg",
model_type="vit_l", # vit_l, vit_h, vit_b
input_point=[[100, 100], [200, 200]],
input_label=[0, 1],
input_box=[100, 100, 200, 200], # or [[100, 100, 200, 200], [100, 100, 200, 200]]
multimask_output=False,
random_color=False,
show=True,
save=False,
)# For video
results = SegManualMaskPredictor().video_predict(
source="video.mp4",
model_type="vit_l", # vit_l, vit_h, vit_b
input_point=[0, 0, 100, 100],
input_label=[0, 1],
input_box=None,
multimask_output=False,
random_color=False,
output_path="output.mp4",
)
```### [SAHI](https://github.com/obss/sahi) + Segment Anything
```bash
pip install sahi metaseg
``````python
from metaseg.sahi_predict import SahiAutoSegmentation, sahi_sliced_predictimage_path = "image.jpg"
boxes = sahi_sliced_predict(
image_path=image_path,
detection_model_type="yolov5", # yolov8, detectron2, mmdetection, torchvision
detection_model_path="yolov5l6.pt",
conf_th=0.25,
image_size=1280,
slice_height=256,
slice_width=256,
overlap_height_ratio=0.2,
overlap_width_ratio=0.2,
)SahiAutoSegmentation().image_predict(
source=image_path,
model_type="vit_b",
input_box=boxes,
multimask_output=False,
random_color=False,
show=True,
save=False,
)
```### [FalAI(Cloud GPU)](https://docs.fal.ai/fal-serverless/quickstart) + Segment Anything
```bash
pip install metaseg fal_serverless
fal-serverless auth login
``````python
# For Auto Mask
from metaseg import falai_automask_imageimage = falai_automask_image(
image_path="image.jpg",
model_type="vit_b",
points_per_side=16,
points_per_batch=32,
min_area=0,
)
image.show() # Show image
image.save("output.jpg") # Save image# For Manual Mask
from metaseg import falai_manuelmask_imageimage = falai_manualmask_image(
image_path="image.jpg",
model_type="vit_b",
input_point=[[100, 100], [200, 200]],
input_label=[0, 1],
input_box=[100, 100, 200, 200], # or [[100, 100, 200, 200], [100, 100, 200, 200]],
multimask_output=False,
random_color=False,
)
image.show() # Show image
image.save("output.jpg") # Save image
```
# Extra Features- [x] Support for Yolov5/8, Detectron2, Mmdetection, Torchvision models
- [x] Support for video and web application(Huggingface Spaces)
- [x] Support for manual single multi box and point selection
- [x] Support for pip installation
- [x] Support for SAHI library
- [x] Support for FalAI