MoonDream Query About Images
- Eli the Computer Guy
- Mar 28
- 1 min read


In this lab we use the query() function to ask MoonDream about an image. It can either describe an image, or return a value if your question is true.
python3 -m pip install moondream
python3 -m pip install pillow
download 2B int 8 Model from: https://github.com/vikhyat/moondream
import moondream as md
from PIL import Image
model = md.vl(model='./moondream-2b-int8.mf.gz')
picture = './img.jpeg'
image = Image.open(picture)
encoded_image = model.encode_image(image)
query = 'is this at the beach - answer only YES or NO'
answer = model.query(encoded_image, query)["answer"]
print(query)
print("\nAnswer:", answer)
Comments