MLhacks commited on
Commit
bd66d0c
·
verified ·
1 Parent(s): b41527f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ #Load the Image captioning pipeline
5
+ captioner = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base")
6
+
7
+ # Define the prediction function
8
+ def describe_image(image):
9
+ result = captioner(image)[0]["generated_text"]
10
+ return result
11
+
12
+ # Create the Gradio interface
13
+ gr.Interface(
14
+ fn=describe_image,
15
+ inputs=gr.Image("type=pil"),
16
+ outputs="text",
17
+ title="Image Describer",
18
+ description="Upload an image and this app will describe it!"
19
+ ).launch(share=True)