EduardoPach / grounded-sam

This repository is a simple display of how to combine Grounding DINO and SAM models
Apache License 2.0
4 stars 0 forks source link

Jupyter notebook implementation? #1

Closed martintomov closed 5 months ago

martintomov commented 5 months ago

Hi,

I'm interested if this implementation of grounded-sam could be used in a notebook environment.

I have a fine-tuned SAM model and I would like to make it work with Grounding DINO for advanced object detection for a particular use-case.

EduardoPach commented 5 months ago

@martintmv-git this is a very naive implementation, but if you want to test it out you can pip install git+https://github.com/EduardoPach/grounded-sam.git and then, if your fine-tuned Sam model is at hugging face hub, do something like:

from grounded_sam.inference import grounded_segmentation
from grounded_sam.plot import plot_detections_plotly, plot_detections

# This can be a path or an URL or a PIL/numpy image
image = ...
# This should be a list of strings representing the labels
labels = ...

image_array, detections = grounded_segmentation(image, labels, segmenter_id="<PATH_TO_YOUR_MODEL_IN_HF>")

You can also refer to this notebook which is the same implementation I have in this repo, but not packaged