vsrinivas's picture
Update app.py
90f40d0
raw
history blame contribute delete
748 Bytes
import gradio as gr
from transformers import pipeline
get_completion = pipeline("image-to-text",model="Salesforce/blip-image-captioning-base")
def captioner(image):
result = get_completion(image)
return result[0]['generated_text']
gr.close_all()
demo = gr.Interface(fn=captioner,
inputs=[gr.Image(label="Upload image", type="pil")],
outputs=[gr.Textbox(label="Caption")],
title="Image Captioning",
description="Generate a caption for any image",
allow_flagging="never",
examples=["data/dog.jpeg",
"data/batman.jpg",
"data/bricks.jpg"])
demo.launch()