autodistill / autodistill-grounded-sam

GroundedSAM Base Model plugin for Autodistill
https://docs.autodistill.com
Apache License 2.0
44 stars 8 forks source link

It’s GroundedSAM always for free or not? #12

Closed Siwakonrome closed 2 months ago

Siwakonrome commented 4 months ago

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[classid]} {confidence:0.2f}" for , _, confidence, classid, 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))

capjamesg commented 2 months ago

Grounded SAM is free to use on your hardware.