adriansmpblcis commited on
Commit
2fbb503
·
verified ·
1 Parent(s): a89eac1

Create app.py

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