Skip to main content

Model for use with Autodistill

Project description

⚠️ This is an example README for use in creating a Base Model. You will need to adjust this document for the model you are using.

Autodistill Grounded EdgeSAM Module

This repository contains the code supporting the Grounded EdgeSAM base model for use with Autodistill.

EdgeSAM, introduced in the "EdgeSAM: Prompt-In-the-Loop Distillation for On-Device Deployment of SAM" paper, is a faster version of the Segment Anything model.

Grounded EdgeSAM combines Grounding DINO and EdgeSAM, allowing you to identify objects and generate segmentation masks for them.

Read the full Autodistill documentation to learn more about Autodistill.

Installation

To use Grounded EdgeSAM with autodistill, you need to install the following dependency:

pip3 install autodistill-grounded-edgesam

Quickstart

from autodistill_clip import CLIP

# 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
from autodistill_grounded_edgesam import GroundedEdgeSAM
from autodistill.detection import CaptionOntology
from autodistill.utils import plot
import cv2

# define an ontology to map class names to our GroundedSAM 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 = GroundedEdgeSAM(
    ontology=CaptionOntology(
        {
            "person": "person",
            "forklift": "forklift",
        }
    )
)

# run inference on a single image
results = base_model.predict("logistics.jpeg")

plot(
    image=cv2.imread("logistics.jpeg"),
    classes=base_model.ontology.classes(),
    detections=results
)

# label a folder of images
base_model.label("./context_images", extension=".jpeg")

License

This repository is released under an S-Lab License 1.0 license.

🏆 Contributing

We love your input! Please see the core Autodistill contributing guide to get started. Thank you 🙏 to all our contributors!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autodistill-grounded-edgesam-0.1.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file autodistill-grounded-edgesam-0.1.0.tar.gz.

File metadata

File hashes

Hashes for autodistill-grounded-edgesam-0.1.0.tar.gz
Algorithm Hash digest
SHA256 baa0bc0308a03cfe2392f620492565254fcaaa19ae6140782652a2e6c3f87b1e
MD5 cacfb9b0061876335558424c481c4c11
BLAKE2b-256 3ec4f7051a5ff31cec5946969015fb90b6fc7cce70a66275749300a074f6f444

See more details on using hashes here.

File details

Details for the file autodistill_grounded_edgesam-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for autodistill_grounded_edgesam-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d2a22490d24f417a39219e29ed7b1f0805627795e4e29120601f2cba392f2853
MD5 9ba55d28e1601627def2c381e8c75c31
BLAKE2b-256 0a5ca5cc54b948d90baa91a3fc5bcaddfc50563cdd20674ed5678e3811035855

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page