This repository contains the code implementing GroundedSAM as a Base Model for use with autodistill
.
GroundedSAM combines GroundingDINO with the Segment Anything Model to identify and segment objects in an image given text captions.
Read the full Autodistill documentation.
Read the GroundedSAM Autodistill documentation.
To use the GroundedSAM Base Model, simply install it along with a Target Model supporting the detection
task:
pip3 install autodistill-grounded-sam autodistill-yolov8
You can find a full list of detection
Target Models on the main autodistill repo.
from autodistill_grounded_sam import GroundedSAM
from autodistill_yolov8 import YOLOv8
# define an ontology to map class names to our GroundingDINO prompt
# the ontology dictionary has the format {caption: class}
# where caption is the prompt sent to the base model, and class is the label that will
# be saved for that caption in the generated annotations
# then, load the model
base_model = GroundedSAM(ontology=CaptionOntology({"shipping container": "container"}))
# label all images in a folder called `context_images`
base_model.label("./context_images", extension=".jpeg")
The code in this repository is licensed under an Apache 2.0 license.
We love your input! Please see the core Autodistill contributing guide to get started. Thank you 🙏 to all our contributors!