Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from transformers import pipeline | |
| image_to_text = pipeline("image-to-text", model="nlpconnect/vit-gpt2-image-captioning") | |
| def generate_caption(img): | |
| caption = image_to_text(img) | |
| return caption[0]['generated_text'] | |
| demo = gr.Interface( | |
| fn = generate_caption, | |
| inputs = gr.Image(type = 'filepath'), | |
| outputs = gr.Textbox(lines = 2), | |
| ) | |
| demo.launch() |