created app.py for the first time
Browse filesfirst time creating an app api on Space following instructions from
https://learn.deeplearning.ai/courses/open-source-models-hugging-face/lesson/15/deployment
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']))
|