fix(vqa): handle Moondream point and detect tasks

Add handlers for "Point at..." and "Detect..." tasks in moondream()
that were falling through to answer_question() and failing.
This commit is contained in:
CalamitousFelicitousness
2025-12-04 21:48:06 +00:00
parent 506515b018
commit c75a09be83
+8 -3
View File
@@ -1111,11 +1111,16 @@ def moondream(question: str, image: Image.Image, repo: str = None, model_name: s
response = model.caption(image, length="normal")['caption']
elif question == 'MORE DETAILED CAPTION':
response = model.caption(image, length="long")['caption']
elif question.lower().startswith('point at '):
target = question[9:]
result = model.point(image, target)
response = str(result)
elif question.lower().startswith('detect '):
target = question[7:]
result = model.detect(image, target)
response = str(result)
else:
response = model.answer_question(encoded, question, processor)['answer']
# model.detect(image, "face")
# model.point(image, "person")
# model.detect_gaze(image)
return response