moondream icon indicating copy to clipboard operation
moondream copied to clipboard

Example of object detection in docs

Open pavanramkumar opened this issue 4 months ago • 2 comments

It would be great to have a simple example of object detection in the documentation so I can reproduce it. I currently tried to use the detect method, but I'm likely using the wrong model version.

from transformers import AutoModelForCausalLM, AutoTokenizer
from PIL import Image

model_id = "vikhyatk/moondream2"
revision = "2024-07-23"
model = AutoModelForCausalLM.from_pretrained(
    model_id, trust_remote_code=True, revision=revision
)
tokenizer = AutoTokenizer.from_pretrained(model_id, revision=revision)

I load input_image with PIL. Then...

enc_image = model.encode_image(input_image)
generated_boxes = model.detect(enc_image, question, tokenizer)

returns:

AttributeError: 'Moondream' object has no attribute 'detect'

pavanramkumar avatar Oct 03 '24 15:10 pavanramkumar