Download app.py from PRUTHVIn/vqa_project: direct link, hf CLI and curl.
- Browser
- Download file 867 Bytes
-
https://huggingface.co/PRUTHVIn/vqa_project/resolve/main/app.py
- Command line
-
hf download hf://PRUTHVIn/vqa_project/app.py
-
curl -L -o app.py https://huggingface.co/PRUTHVIn/vqa_project/resolve/main/app.py
867 Bytes
| 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() |