Spaces:
Runtime error
Runtime error
File size: 575 Bytes
c8465bf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
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."
)
iface.launch(inline = False)
|