File size: 471 Bytes
31a7455
5d00e2d
31a7455
6f419af
 
 
 
5d00e2d
6f419af
c7102bb
3326aa9
31a7455
6f419af
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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()