Spaces:
Sleeping
Sleeping
Download app.py from helloboy1234/image_vqa_appppp: direct link, hf CLI and curl.
- Browser
- Download file 841 Bytes
-
https://huggingface.co/spaces/helloboy1234/image_vqa_appppp/resolve/main/app.py
- Command line
-
hf download hf://spaces/helloboy1234/image_vqa_appppp/app.py
-
curl -L -o app.py https://huggingface.co/spaces/helloboy1234/image_vqa_appppp/resolve/main/app.py
841 Bytes
| import gradio as gr | |
| from transformers import BlipProcessor, BlipForQuestionAnswering | |
| from PIL import Image | |
| # 모델 로드 | |
| processor = BlipProcessor.from_pretrained("Salesforce/blip-vqa-base") | |
| model = BlipForQuestionAnswering.from_pretrained("Salesforce/blip-vqa-base") | |
| def answer_question(image, question): | |
| inputs = processor(image, question, return_tensors="pt") | |
| out = model.generate(**inputs) | |
| answer = processor.decode(out[0], skip_special_tokens=True) | |
| return answer | |
| # Gradio UI | |
| demo = gr.Interface( | |
| fn=answer_question, | |
| inputs=[ | |
| gr.Image(type="pil"), | |
| gr.Textbox(label="질문 입력") | |
| ], | |
| outputs="text", | |
| title="🖼️ 이미지 질문 답변 AI", | |
| description="이미지를 업로드하고 질문을 입력하면 AI가 답변합니다." | |
| ) | |
| demo.launch() |