Spaces:
Sleeping
Sleeping
Commit
·
6f419af
1
Parent(s):
c7102bb
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,17 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
result = classifier(text, candidate_labels)
|
| 10 |
-
|
| 11 |
-
result = dict(zip(result['labels'], result['scores']))
|
| 12 |
|
| 13 |
return result
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Rename 'text' to 'image'
|
| 5 |
+
def do_action(image):
|
| 6 |
+
# Use the blip model
|
| 7 |
+
pipe = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
|
| 8 |
|
| 9 |
+
result = pipe(image)
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
return result
|
| 12 |
|
| 13 |
+
# input image, output text
|
| 14 |
+
# can't use inputs="image"
|
| 15 |
+
# instead use inputs=gr.Image(type='pil')
|
| 16 |
+
iface = gr.Interface(fn=do_action, inputs=gr.Image(type='pil'), outputs="text")
|
| 17 |
+
iface.launch()
|