Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Written On: 10 Feb 2025
|
2 |
+
Last Updaate: 10 Feb 2025
|
3 |
+
|
4 |
+
#from transformers.utils import logging
|
5 |
+
#logging.set_verbosity_error()
|
6 |
+
|
7 |
+
#import warnings
|
8 |
+
#warnings.filterwarnings("ignore",
|
9 |
+
# message="Using the model-agnostic default `max_length`")
|
10 |
+
|
11 |
+
import os
|
12 |
+
import gradio as gr
|
13 |
+
from transformers import pipeline
|
14 |
+
|
15 |
+
pipe = pipeline("image-to-text",
|
16 |
+
model="./models/Salesforce/blip-image-captioning-base")
|
17 |
+
|
18 |
+
def launch(input):
|
19 |
+
out = pipe(input)
|
20 |
+
return out[0]['generated_text']
|
21 |
+
|
22 |
+
iface = gr.Interface(launch,
|
23 |
+
inputs=gr.Image(type='pil'),
|
24 |
+
outputs="text")
|
25 |
+
|
26 |
+
#iface.launch(share=True,
|
27 |
+
# server_port=int(os.environ['PORT1']))
|
28 |
+
|
29 |
+
iface.launch()
|