refactor(vqa): convert to class-based singleton

Refactor VQA module from module-level globals to a VQA class singleton
  pattern with self-contained per-model loading methods.

Changes:
- Add VQA class with model/processor state and detection data storage
- Extract load methods for clean model pre-loading via UI
- Interrogate to return string only; store detection data on instance
- Add vqa_draw.py for bounding box/point annotation utilities
    Stub, further transfer of drawing functions to follow
- Update moondream3.py to store detection data on VQA singleton
- Update endpoints.py and ui_caption.py for new return type
This commit is contained in:
CalamitousFelicitousness
2025-12-05 20:53:18 +00:00
parent d1b1d574a6
commit 5193285bc7
5 changed files with 1155 additions and 1123 deletions
+1 -1
View File
@@ -100,7 +100,7 @@ def post_vqa(req: models.ReqVQA):
image = helpers.decode_base64_to_image(req.image)
image = image.convert('RGB')
from modules.interrogate import vqa
answer, _ = vqa.interrogate(req.question, req.system, '', image, req.model)
answer = vqa.interrogate(req.question, req.system, '', image, req.model)
return models.ResVQA(answer=answer)
def post_unload_checkpoint():