Brice Vandeputte
commited on
Commit
·
d682b63
1
Parent(s):
6bde7ff
provide input image used, and demo context
Browse files
app.py
CHANGED
@@ -16,7 +16,7 @@ def api_classification(url):
|
|
16 |
if url_to_use == "exemple":
|
17 |
url_to_use = "https://images.pexels.com/photos/326900/pexels-photo-326900.jpeg?cs=srgb&dl=pexels-pixabay-326900.jpg&fm=jpg"
|
18 |
predictions = svc.predict(url_to_use)
|
19 |
-
return json.dumps(predictions)
|
20 |
|
21 |
|
22 |
with gr.Blocks() as app:
|
@@ -24,23 +24,43 @@ with gr.Blocks() as app:
|
|
24 |
with gr.Row():
|
25 |
with gr.Column():
|
26 |
# https://www.gradio.app/guides/key-component-concepts
|
27 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
api_input = gr.Textbox(
|
29 |
-
placeholder="Image url here",
|
30 |
lines=1,
|
31 |
-
label="
|
32 |
-
show_label=
|
33 |
info="Add image url here.",
|
34 |
value="https://natureconservancy-h.assetsadobe.com/is/image/content/dam/tnc/nature/en/photos/d/o/Downy-woodpecker-Matt-Williams.jpg?crop=0%2C39%2C3097%2C2322&wid=820&hei=615&scl=3.776829268292683"
|
35 |
)
|
36 |
-
api_classification_btn = gr.Button("
|
|
|
37 |
with gr.Column():
|
38 |
-
|
39 |
|
40 |
api_classification_btn.click(
|
41 |
fn=api_classification,
|
42 |
inputs=[api_input],
|
43 |
-
outputs=[
|
44 |
)
|
45 |
app.queue(max_size=20)
|
46 |
app.launch()
|
|
|
16 |
if url_to_use == "exemple":
|
17 |
url_to_use = "https://images.pexels.com/photos/326900/pexels-photo-326900.jpeg?cs=srgb&dl=pexels-pixabay-326900.jpg&fm=jpg"
|
18 |
predictions = svc.predict(url_to_use)
|
19 |
+
return json.dumps(predictions), url_to_use
|
20 |
|
21 |
|
22 |
with gr.Blocks() as app:
|
|
|
24 |
with gr.Row():
|
25 |
with gr.Column():
|
26 |
# https://www.gradio.app/guides/key-component-concepts
|
27 |
+
gr.HTML(value="""
|
28 |
+
This <a href="https://huggingface.co/spaces/3oly/grBird">Gradio BioCLIP API</a> is a <a href="https://github.com/Imageomics/bioclip">BioCLIP</a> based prediction.<br/><br/>
|
29 |
+
<small>origin is a <a href="https://huggingface.co/spaces/imageomics/bioclip-demo">BioCLIP DEMO</a>
|
30 |
+
<a href="https://huggingface.co/spaces/imageomics/bioclip-demo/discussions/7">discussion</a>
|
31 |
+
following <a href="https://github.com/boly38/pyBird">pyBird</a> MVP.</small>
|
32 |
+
<br/>
|
33 |
+
<h2>How to use Gradio UI ?</h2>
|
34 |
+
<ul>
|
35 |
+
<li>You must input a <b>public url of an image</b> and submit by clicking on "predict".</li>
|
36 |
+
<li>You will get TreeOfLife predictions as result.</li>
|
37 |
+
</ul>
|
38 |
+
<h2>How to use Gradio API (Node.js, Python, Bash Curl) ?</h2>
|
39 |
+
<ul>
|
40 |
+
<li>You must follow the demo footer link called "Use via API". There is some example provided.</li>
|
41 |
+
</ul>
|
42 |
+
<h2>Credits</h2>
|
43 |
+
<ul>
|
44 |
+
<li>This API endpoint is (only) an augmented fork of the <a href="https://github.com/Imageomics/bioclip">BioCLIP</a> : a wrapper that provide another form of API call.</li>
|
45 |
+
<li>Research context, model, and contact are available at <a href="https://github.com/Imageomics/bioclip">Imageomics/bioclip</a>.</li>
|
46 |
+
</ul>
|
47 |
+
""", show_label=False)
|
48 |
api_input = gr.Textbox(
|
|
|
49 |
lines=1,
|
50 |
+
label="Input a public image url",
|
51 |
+
show_label=False,
|
52 |
info="Add image url here.",
|
53 |
value="https://natureconservancy-h.assetsadobe.com/is/image/content/dam/tnc/nature/en/photos/d/o/Downy-woodpecker-Matt-Williams.jpg?crop=0%2C39%2C3097%2C2322&wid=820&hei=615&scl=3.776829268292683"
|
54 |
)
|
55 |
+
api_classification_btn = gr.Button("predict", variant="primary")
|
56 |
+
api_classification_output_gallery = gr.Image(label="Input image used")
|
57 |
with gr.Column():
|
58 |
+
api_classification_output_json = gr.JSON(label="This is classification result") # https://www.gradio.app/docs/gradio/json
|
59 |
|
60 |
api_classification_btn.click(
|
61 |
fn=api_classification,
|
62 |
inputs=[api_input],
|
63 |
+
outputs=[api_classification_output_json, api_classification_output_gallery],
|
64 |
)
|
65 |
app.queue(max_size=20)
|
66 |
app.launch()
|