File size: 599 Bytes
b880f89
 
 
 
e6fd7a9
b880f89
 
 
 
 
 
 
 
 
 
9bff8d5
 
b880f89
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import gradio as gr
from transformers import pipeline

pipe = pipeline("image-to-text",
                model="Salesforce/blip-image-captioning-base", force_download=True)


def launch(input):
    out = pipe(input)
    return out[0]['generated_text']

iface = gr.Interface(launch,
                     inputs=[gr.Image(label="Upload image", type="pil")],
                    outputs=[gr.Textbox(label="Caption")],
                    title="ImageLexica",
                    description="Generate captions for any image from your Gallery",
                    allow_flagging="never")

iface.launch()