siamaky1984 commited on
Commit
ce48edc
·
verified ·
1 Parent(s): 6c84e64

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from transformers import pipeline
4
+
5
+ from transformers.utils import logging
6
+ logging.set_verbosity_error()
7
+
8
+ import warnings
9
+ warnings.filterwarnings("ignore",
10
+ message="Using the model-agnostic default `max_length`")
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
+ iface = gr.Interface(launch,
20
+ inputs=gr.Image(type='pil'),
21
+ outputs="text")
22
+
23
+ iface.launch(share=True,
24
+ server_port=int(os.environ['PORT1']))