Spaces:
Running
Running
Update index.html
#1
by
whitphx
HF staff
- opened
- index.html +3 -3
index.html
CHANGED
@@ -30,7 +30,7 @@ transformers_js_py
|
|
30 |
</gradio-requirements>
|
31 |
|
32 |
<gradio-file name="app.py" entrypoint>
|
33 |
-
from transformers_js import import_transformers_js
|
34 |
import gradio as gr
|
35 |
|
36 |
transformers = await import_transformers_js()
|
@@ -38,8 +38,8 @@ pipeline = transformers.pipeline
|
|
38 |
pipe = await pipeline('zero-shot-image-classification')
|
39 |
|
40 |
async def classify(image, classes):
|
41 |
-
data = await pipe(image, classes.split(","))
|
42 |
-
result =
|
43 |
return result
|
44 |
|
45 |
demo = gr.Interface(classify, [gr.Image(label="Input image", type="filepath"), gr.Textbox(label="Classes separated by commas")], gr.Label())
|
|
|
30 |
</gradio-requirements>
|
31 |
|
32 |
<gradio-file name="app.py" entrypoint>
|
33 |
+
from transformers_js import import_transformers_js, as_url
|
34 |
import gradio as gr
|
35 |
|
36 |
transformers = await import_transformers_js()
|
|
|
38 |
pipe = await pipeline('zero-shot-image-classification')
|
39 |
|
40 |
async def classify(image, classes):
|
41 |
+
data = await pipe(as_url(image), classes.split(","))
|
42 |
+
result = {item['label']: round(item['score'], 2) for item in data}
|
43 |
return result
|
44 |
|
45 |
demo = gr.Interface(classify, [gr.Image(label="Input image", type="filepath"), gr.Textbox(label="Classes separated by commas")], gr.Label())
|