GlenJay2004 commited on
Commit
dd04c5e
·
verified ·
1 Parent(s): 5b2f2f7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Filter the warnings
2
+ import warnings
3
+ warnings.filterwarnings('ignore')
4
+ from transformers import logging
5
+ logging.set_verbosity_error()
6
+
7
+ #Import the necessary
8
+ import gradio as gr
9
+ from transformers import pipeline
10
+
11
+ #Perform Image Captioning
12
+ get_completion = pipeline("image-to-text",model="Salesforce/blip-image-captioning-base")
13
+
14
+ #Launch the input
15
+ def launch(input):
16
+ out=get_completion(input)
17
+ return out[0]['generated_text']
18
+
19
+ #Define an interface
20
+ interface=gr.Interface(fn=launch,inputs=gr.Image(type="pil"),outputs="text",title="Image Captioning with BLIP")
21
+
22
+ interface.launch()
23
+