knslee07 commited on
Commit
205df06
·
verified ·
1 Parent(s): 8636f19

created app.py for the first time

Browse files

first time creating an app api on Space following instructions from
https://learn.deeplearning.ai/courses/open-source-models-hugging-face/lesson/15/deployment

Files changed (1) hide show
  1. app.py +13 -0
app.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from transformers import pipeline
4
+ pipe = pipeline("image-to-text",
5
+ model="Salesforce/blip-image-captioning-base")
6
+ def launch(input):
7
+ out = pipe(input)
8
+ return out[0]['generated_text']
9
+
10
+ iface = gr.Interface(launch,
11
+ inputs=gr.Image(type='pil'),
12
+ outputs="text")
13
+ iface.launch()#share=True)#,server_port=int(os.environ['PORT1']))