Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
image_url = "https://free-images.com/sm/9596/dog_animal_greyhound_983023.jpg" | |
get_completion = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base") | |
def summarize(input): | |
output = get_completion(input) | |
return output[0]['generated_text'] | |
import gradio as gr | |
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="Caption any image using the model-Salesforce/blip-image-captioning-base", | |
allow_flagging="never") | |
demo.launch() | |