Spaces:
Runtime error
Runtime error
File size: 578 Bytes
c8465bf 8b4c3aa c8465bf 8b4c3aa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import gradio as gr
from transformers import pipeline
# Image to text function
def image2text(image_path):
captioner = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
text = captioner(image_path)[0]['generated_text']
return text
# Gradio interface
iface = gr.Interface(
fn=image2text,
inputs=gr.Image(type="filepath", label="Upload Image"),
outputs="text",
title="Image Description Generator",
description="Upload an image and get a generated description."
)
if __name__ == "__main__":
iface.launch(inline=False)
|