File size: 528 Bytes
bd66d0c
 
 
 
 
 
 
 
 
 
 
 
 
 
183745b
bd66d0c
 
 
 
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

#Load the Image captioning pipeline
captioner = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base") 

# Define the prediction function
def describe_image(image):
  result = captioner(image)[0]["generated_text"]
  return result

# Create the Gradio interface
gr.Interface(
  fn=describe_image,
  inputs=gr.Image(type="pil"),
  outputs="text",
  title="Image Describer",
  description="Upload an image and this app will describe it!"
).launch(share=True)