File size: 867 Bytes
364daa0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b35ce1
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
import gradio as gr
from inference import predict

def vqa_interface(image, question):
    try:
        if image is None or question.strip() == "":
            return "Please upload an image and enter a question."

        answer = predict(image, question)
        return answer

    except Exception as e:
        print("ERROR:", str(e))
        return f"Error: {str(e)}"


iface = gr.Interface(
    fn=vqa_interface,
    inputs=[
        gr.Image(type="filepath", label="Upload Image"),
        gr.Textbox(
            label="Ask a Question",
            placeholder="e.g. What is in the image?"
        )
    ],
    outputs=gr.Textbox(label="Answer"),
    title="🧠 Smart Visual Question Answering System",
    description="Upload any image and ask anything (works for medical + general images)",
    theme="soft"
)

if __name__ == "__main__":
    iface.launch()