Spaces:
Sleeping
Sleeping
File size: 591 Bytes
1da5841 3bfce0f 1da5841 9cf29f4 1da5841 9cf29f4 3bfce0f 1da5841 9b6e5c0 1da5841 3bfce0f 9cf29f4 1da5841 3bfce0f 19026d5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import gradio as gr
from transformers import pipeline
pipe = pipeline("image-to-text", model="nlpconnect/vit-gpt2-image-captioning")
def generate_caption(image):
result = pipe(image)
return result[0]["generated_text"].strip()
title = "🖼️ Image Caption Generator"
description = "Upload an image and get a caption"
demo = gr.Interface(
fn=generate_caption,
inputs=gr.Image(type="pil"),
outputs=gr.Textbox(label="Generated Caption"),
title=title,
description=description,
flagging_mode="never"
)
if __name__ == "__main__":
demo.launch(share=False)
|