priyamarwaha commited on
Commit
818786c
·
verified ·
1 Parent(s): ed4e582

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers.utils import logging
2
+ import gradio as gr
3
+ from transformers import pipeline
4
+ import warnings
5
+
6
+ warnings.filterwarnings("ignore",
7
+ message="Using the model-agnostic default `max_length`")
8
+
9
+ logging.set_verbosity_error()
10
+ pipe = pipeline("image-to-text",
11
+ model="Salesforce/blip-image-captioning-base")
12
+
13
+ def launch(input):
14
+ out = pipe(input)
15
+ return out[0]['generated_text']
16
+
17
+ iface = gr.Interface(launch,
18
+ inputs=gr.Image(type='pil'),
19
+ outputs="text")
20
+ iface.launch()