Spaces:
Runtime error
Runtime error
Download app.py from Babyloncoder/chat-with-an-image: direct link, hf CLI and curl.
- Browser
- Download file 581 Bytes
-
https://huggingface.co/spaces/Babyloncoder/chat-with-an-image/resolve/main/app.py
- Command line
-
hf download hf://spaces/Babyloncoder/chat-with-an-image/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Babyloncoder/chat-with-an-image/resolve/main/app.py
581 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the VQA model | |
| oracle = pipeline(model="dandelin/vilt-b32-finetuned-vqa") | |
| # Define a function to use the model | |
| def answer_question(image, question): | |
| response = oracle(question=question, image=image) | |
| return response[0]['answer'] | |
| # Import the specific input and output components directly | |
| from gradio import Image, Textbox | |
| # Create the Gradio interface | |
| interface = gr.Interface( | |
| fn=answer_question, | |
| inputs=[Image(type="filepath"), Textbox()], | |
| outputs=Textbox() | |
| ) | |
| # Launch the app | |
| interface.launch() |