wendys-llc's picture
Update app.py
3326aa9
raw
history blame contribute delete
No virus
471 Bytes
import gradio as gr
from transformers import pipeline
# Rename 'text' to 'image'
def do_action(image):
# Use the blip model
pipe = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
result = pipe(image)
return result[0]['generated_text']
# input image, output text
# can't use inputs="image"
# instead use inputs=gr.Image(type='pil')
iface = gr.Interface(fn=do_action, inputs=gr.Image(type='pil'), outputs="text")
iface.launch()