Image-to-Text / app.py
abhi227070's picture
Create app.py
33a6854 verified
raw
history blame contribute delete
429 Bytes
from transformers import pipeline
from PIL import Image
import gradio as gr
model = None
if model == None:
model = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
def captioner(image):
img = Image.fromarray(image)
result = model(img)[0]['generated_text']
return result
iface = gr.Interface(
fn = captioner,
inputs = gr.Image(),
outputs = 'text'
)
iface.launch()