Spaces:
Runtime error
Runtime error
File size: 385 Bytes
ffe7bc8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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() |