Spaces:
Sleeping
Sleeping
File size: 1,018 Bytes
e23acaf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | from src.multimodal.multimodal_rag_chain import MultimodalRAG
from src.visualization.llm_structure_extractor import StructureExtractor
from src.visualization.image_annotator import ImageAnnotator
# 🔥 Global instances (load once for API performance)
rag = MultimodalRAG()
extractor = StructureExtractor()
annotator = ImageAnnotator()
def run_visual_answer(question: str):
"""
FastAPI entry point for anatomical visual highlighting.
Returns:
{
"annotated_image": str
}
"""
answer, images = rag.ask(question)
if not images:
return {
"annotated_image": None
}
structures = extractor.extract(question)
annotated = annotator.annotate(images[0], structures)
return {
"annotated_image": annotated
}
def main():
while True:
query = input("\nAsk: ")
result = run_visual_answer(query)
print("\nANNOTATED IMAGE:", result["annotated_image"])
if __name__ == "__main__":
main()
|