Skip to content

It’s GroundedSAM free or not? #277

Closed
@Siwakonrome

Description

@Siwakonrome

Search before asking

  • I have searched the Roboflow Notebooks issues and found no similar bug report.

Description

It’s GroundedSAM free or not? If not How to get Api key to using this service?

import cv2
import supervision as sv
from autodistill_grounded_sam import GroundedSAM
from autodistill.detection import CaptionOntology

class GroundedSAMOperator:

def init(self, caption):
self.caption = caption
self.base_model = GroundedSAM(ontology=CaptionOntology(self.caption))
self.classes = base_model.ontology.classes()

def call(self, image):
detections = self.base_model.predict(image)
labels = [f"{self.classes[class_id]} {confidence:0.2f}" for _, _, confidence, class_id, _ in detections]
print(labels)
return detections

image = cv2.imread("/content/aluminum.jpg")
caption = { "aluminum workpiece": "aluminum" }
grounded_sam_operator = GroundedSAMOperator(caption)
detections = grounded_sam_operator(image)

mask_annotator = sv.MaskAnnotator()

annotated_frame = mask_annotator.annotate(
scene=image.copy(),
detections=detections)

sv.plot_image(annotated_frame, size=(8, 8))

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions