Spaces:
Running
Running
sashavor
commited on
Commit
•
3e5aff4
1
Parent(s):
87d659a
adding wiki
Browse files- app.py +17 -2
- gradio_cached_examples/12/component 0/02d7188e-0870-4b9e-937a-18a13327a52a/captions.json +1 -0
- gradio_cached_examples/12/component 0/02d7188e-0870-4b9e-937a-18a13327a52a/tmp46c41jzvpfg__jaf.png +0 -0
- gradio_cached_examples/12/component 0/02d7188e-0870-4b9e-937a-18a13327a52a/tmp7fyeplby_bd96sed.png +0 -0
- gradio_cached_examples/12/component 0/02d7188e-0870-4b9e-937a-18a13327a52a/tmpbbu961rsx8ck70mt.png +0 -0
- gradio_cached_examples/12/component 0/02d7188e-0870-4b9e-937a-18a13327a52a/tmpxot6kk3fzlntjwpg.png +0 -0
- gradio_cached_examples/12/component 0/45f9d195-37f2-44a4-b76a-7cc600807802/captions.json +1 -0
- gradio_cached_examples/12/component 0/45f9d195-37f2-44a4-b76a-7cc600807802/tmp_4c5qekxj97hhoy_.png +0 -0
- gradio_cached_examples/12/component 0/45f9d195-37f2-44a4-b76a-7cc600807802/tmpe13rsihgygprlgvr.png +0 -0
- gradio_cached_examples/12/component 0/45f9d195-37f2-44a4-b76a-7cc600807802/tmpfrwm45jz74u6nw5r.png +0 -0
- gradio_cached_examples/12/component 0/45f9d195-37f2-44a4-b76a-7cc600807802/tmpqj3o9sz_3xds6xim.png +0 -0
- gradio_cached_examples/12/component 0/57843eb6-2d89-4dc8-b9d8-2df141adbeea/captions.json +1 -0
- gradio_cached_examples/12/component 0/57843eb6-2d89-4dc8-b9d8-2df141adbeea/tmp22me_1n0ec67rz7i.png +0 -0
- gradio_cached_examples/12/component 0/57843eb6-2d89-4dc8-b9d8-2df141adbeea/tmpcn68ewpb_k_k14b_.png +0 -0
- gradio_cached_examples/12/component 0/57843eb6-2d89-4dc8-b9d8-2df141adbeea/tmpeaq3qfr6qa28hx7a.png +0 -0
- gradio_cached_examples/12/component 0/57843eb6-2d89-4dc8-b9d8-2df141adbeea/tmpo5mlr0p45a8s18y_.png +0 -0
- gradio_cached_examples/12/component 0/ff8fd254-c0ac-41cb-b011-307f455a9b1f/captions.json +1 -0
- gradio_cached_examples/12/component 0/ff8fd254-c0ac-41cb-b011-307f455a9b1f/tmp3xr29xm_i1wgozul.png +0 -0
- gradio_cached_examples/12/component 0/ff8fd254-c0ac-41cb-b011-307f455a9b1f/tmpeh6zb8v35jn2hdyg.png +0 -0
- gradio_cached_examples/12/component 0/ff8fd254-c0ac-41cb-b011-307f455a9b1f/tmpitx1oyqi8i4rw_uj.png +0 -0
- gradio_cached_examples/12/component 0/ff8fd254-c0ac-41cb-b011-307f455a9b1f/tmpolb51saoxzub9uo3.png +0 -0
- gradio_cached_examples/12/component 1/tmp0oj7zte5.json +1 -0
- gradio_cached_examples/12/component 1/tmp856oniiz.json +1 -0
- gradio_cached_examples/12/component 1/tmp93ewyfy8.json +1 -0
- gradio_cached_examples/12/component 1/tmpoq_i04_o.json +1 -0
- gradio_cached_examples/12/log.csv +5 -0
- lsh.pickle +0 -3
app.py
CHANGED
@@ -2,6 +2,7 @@ import pickle
|
|
2 |
import gradio as gr
|
3 |
from datasets import load_dataset
|
4 |
from transformers import AutoModel, AutoFeatureExtractor
|
|
|
5 |
|
6 |
|
7 |
# Only runs once when the script is first run.
|
@@ -29,7 +30,18 @@ def query(image, top_k=4):
|
|
29 |
images_with_captions = [(i, c) for i, c in zip(images,captions)]
|
30 |
labels_with_probs = dict(zip(captions,logits))
|
31 |
labels_with_probs = {k: 1- v for k, v in labels_with_probs.items()}
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
|
35 |
with gr.Blocks() as demo:
|
@@ -39,9 +51,12 @@ with gr.Blocks() as demo:
|
|
39 |
with gr.Column(min_width= 900):
|
40 |
inputs = gr.Image(shape=(800, 1600))
|
41 |
btn = gr.Button("Find my butterfly!")
|
|
|
|
|
42 |
with gr.Column():
|
43 |
outputs=gr.Gallery().style(grid=[2], height="auto")
|
44 |
labels = gr.Label()
|
|
|
45 |
gr.Markdown("### Image Examples")
|
46 |
gr.Examples(
|
47 |
examples=["elton.jpg", "ken.jpg", "gaga.jpg", "taylor.jpg"],
|
@@ -50,7 +65,7 @@ with gr.Blocks() as demo:
|
|
50 |
fn=query,
|
51 |
cache_examples=True,
|
52 |
)
|
53 |
-
btn.click(query, inputs, [outputs, labels])
|
54 |
|
55 |
demo.launch()
|
56 |
|
|
|
2 |
import gradio as gr
|
3 |
from datasets import load_dataset
|
4 |
from transformers import AutoModel, AutoFeatureExtractor
|
5 |
+
import wikipedia
|
6 |
|
7 |
|
8 |
# Only runs once when the script is first run.
|
|
|
30 |
images_with_captions = [(i, c) for i, c in zip(images,captions)]
|
31 |
labels_with_probs = dict(zip(captions,logits))
|
32 |
labels_with_probs = {k: 1- v for k, v in labels_with_probs.items()}
|
33 |
+
try:
|
34 |
+
description = wikipedia.summary(captions[0], sentences = 1)
|
35 |
+
description = "### " + description
|
36 |
+
url = wikipedia.page(captions[0]).url
|
37 |
+
url = " You can learn more about your butterfly [here](" + str(url) + ")!"
|
38 |
+
description = description + url
|
39 |
+
except:
|
40 |
+
description = "### Butterflies are insects in the order Lepidoptera, which also includes moths. Adult butterflies have large, often brightly coloured wings."
|
41 |
+
url = "https://en.wikipedia.org/wiki/Butterfly"
|
42 |
+
url = " You can learn more about butterflies [here](" + str(url) + ")!"
|
43 |
+
description = description + url
|
44 |
+
return images_with_captions, labels_with_probs, description
|
45 |
|
46 |
|
47 |
with gr.Blocks() as demo:
|
|
|
51 |
with gr.Column(min_width= 900):
|
52 |
inputs = gr.Image(shape=(800, 1600))
|
53 |
btn = gr.Button("Find my butterfly!")
|
54 |
+
description = gr.Markdown()
|
55 |
+
|
56 |
with gr.Column():
|
57 |
outputs=gr.Gallery().style(grid=[2], height="auto")
|
58 |
labels = gr.Label()
|
59 |
+
|
60 |
gr.Markdown("### Image Examples")
|
61 |
gr.Examples(
|
62 |
examples=["elton.jpg", "ken.jpg", "gaga.jpg", "taylor.jpg"],
|
|
|
65 |
fn=query,
|
66 |
cache_examples=True,
|
67 |
)
|
68 |
+
btn.click(query, inputs, [outputs, labels, description])
|
69 |
|
70 |
demo.launch()
|
71 |
|
gradio_cached_examples/12/component 0/02d7188e-0870-4b9e-937a-18a13327a52a/captions.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/02d7188e-0870-4b9e-937a-18a13327a52a/tmpbbu961rsx8ck70mt.png": "Limenitis archippus", "/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/02d7188e-0870-4b9e-937a-18a13327a52a/tmpxot6kk3fzlntjwpg.png": "Limenitis archippus", "/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/02d7188e-0870-4b9e-937a-18a13327a52a/tmp46c41jzvpfg__jaf.png": "Limenitis archippus", "/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/02d7188e-0870-4b9e-937a-18a13327a52a/tmp7fyeplby_bd96sed.png": "Limenitis archippus"}
|
gradio_cached_examples/12/component 0/02d7188e-0870-4b9e-937a-18a13327a52a/tmp46c41jzvpfg__jaf.png
ADDED
gradio_cached_examples/12/component 0/02d7188e-0870-4b9e-937a-18a13327a52a/tmp7fyeplby_bd96sed.png
ADDED
gradio_cached_examples/12/component 0/02d7188e-0870-4b9e-937a-18a13327a52a/tmpbbu961rsx8ck70mt.png
ADDED
gradio_cached_examples/12/component 0/02d7188e-0870-4b9e-937a-18a13327a52a/tmpxot6kk3fzlntjwpg.png
ADDED
gradio_cached_examples/12/component 0/45f9d195-37f2-44a4-b76a-7cc600807802/captions.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/45f9d195-37f2-44a4-b76a-7cc600807802/tmpe13rsihgygprlgvr.png": "Zizina otis", "/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/45f9d195-37f2-44a4-b76a-7cc600807802/tmpfrwm45jz74u6nw5r.png": "Lycaena phlaeas", "/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/45f9d195-37f2-44a4-b76a-7cc600807802/tmpqj3o9sz_3xds6xim.png": "Polyommatus coridon", "/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/45f9d195-37f2-44a4-b76a-7cc600807802/tmp_4c5qekxj97hhoy_.png": "Euchrysops cnejus"}
|
gradio_cached_examples/12/component 0/45f9d195-37f2-44a4-b76a-7cc600807802/tmp_4c5qekxj97hhoy_.png
ADDED
gradio_cached_examples/12/component 0/45f9d195-37f2-44a4-b76a-7cc600807802/tmpe13rsihgygprlgvr.png
ADDED
gradio_cached_examples/12/component 0/45f9d195-37f2-44a4-b76a-7cc600807802/tmpfrwm45jz74u6nw5r.png
ADDED
gradio_cached_examples/12/component 0/45f9d195-37f2-44a4-b76a-7cc600807802/tmpqj3o9sz_3xds6xim.png
ADDED
gradio_cached_examples/12/component 0/57843eb6-2d89-4dc8-b9d8-2df141adbeea/captions.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/57843eb6-2d89-4dc8-b9d8-2df141adbeea/tmp22me_1n0ec67rz7i.png": "Glaucopsyche lygdamus", "/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/57843eb6-2d89-4dc8-b9d8-2df141adbeea/tmpo5mlr0p45a8s18y_.png": "Polyommatus bellargus", "/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/57843eb6-2d89-4dc8-b9d8-2df141adbeea/tmpeaq3qfr6qa28hx7a.png": "Lasaia agesilas", "/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/57843eb6-2d89-4dc8-b9d8-2df141adbeea/tmpcn68ewpb_k_k14b_.png": "Lasaia agesilas"}
|
gradio_cached_examples/12/component 0/57843eb6-2d89-4dc8-b9d8-2df141adbeea/tmp22me_1n0ec67rz7i.png
ADDED
gradio_cached_examples/12/component 0/57843eb6-2d89-4dc8-b9d8-2df141adbeea/tmpcn68ewpb_k_k14b_.png
ADDED
gradio_cached_examples/12/component 0/57843eb6-2d89-4dc8-b9d8-2df141adbeea/tmpeaq3qfr6qa28hx7a.png
ADDED
gradio_cached_examples/12/component 0/57843eb6-2d89-4dc8-b9d8-2df141adbeea/tmpo5mlr0p45a8s18y_.png
ADDED
gradio_cached_examples/12/component 0/ff8fd254-c0ac-41cb-b011-307f455a9b1f/captions.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/ff8fd254-c0ac-41cb-b011-307f455a9b1f/tmp3xr29xm_i1wgozul.png": "Hypolimnas bolina", "/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/ff8fd254-c0ac-41cb-b011-307f455a9b1f/tmpeh6zb8v35jn2hdyg.png": "Aglais io", "/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/ff8fd254-c0ac-41cb-b011-307f455a9b1f/tmpitx1oyqi8i4rw_uj.png": "Aglais io", "/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/ff8fd254-c0ac-41cb-b011-307f455a9b1f/tmpolb51saoxzub9uo3.png": "Aglais io"}
|
gradio_cached_examples/12/component 0/ff8fd254-c0ac-41cb-b011-307f455a9b1f/tmp3xr29xm_i1wgozul.png
ADDED
gradio_cached_examples/12/component 0/ff8fd254-c0ac-41cb-b011-307f455a9b1f/tmpeh6zb8v35jn2hdyg.png
ADDED
gradio_cached_examples/12/component 0/ff8fd254-c0ac-41cb-b011-307f455a9b1f/tmpitx1oyqi8i4rw_uj.png
ADDED
gradio_cached_examples/12/component 0/ff8fd254-c0ac-41cb-b011-307f455a9b1f/tmpolb51saoxzub9uo3.png
ADDED
gradio_cached_examples/12/component 1/tmp0oj7zte5.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"label": "Glaucopsyche lygdamus", "confidences": [{"label": "Glaucopsyche lygdamus", "confidence": 0.11371570782990381}, {"label": "Polyommatus bellargus", "confidence": 0.10690598584467448}, {"label": "Lasaia agesilas", "confidence": 0.09555021409116427}]}
|
gradio_cached_examples/12/component 1/tmp856oniiz.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"label": "Hypolimnas bolina", "confidences": [{"label": "Hypolimnas bolina", "confidence": 0.12392853351469735}, {"label": "Aglais io", "confidence": 0.11333487671741238}]}
|
gradio_cached_examples/12/component 1/tmp93ewyfy8.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"label": "Zizina otis", "confidences": [{"label": "Zizina otis", "confidence": 0.11918760575342546}, {"label": "Lycaena phlaeas", "confidence": 0.11078136057040755}, {"label": "Polyommatus coridon", "confidence": 0.1060889071472263}, {"label": "Euchrysops cnejus", "confidence": 0.10230492569469185}]}
|
gradio_cached_examples/12/component 1/tmpoq_i04_o.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"label": "Limenitis archippus", "confidences": [{"label": "Limenitis archippus", "confidence": 0.06515643324963138}]}
|
gradio_cached_examples/12/log.csv
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
component 0,component 1,flag,username,timestamp
|
2 |
+
/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/02d7188e-0870-4b9e-937a-18a13327a52a,/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 1/tmpoq_i04_o.json,,,2022-12-16 14:02:29.507395
|
3 |
+
/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/ff8fd254-c0ac-41cb-b011-307f455a9b1f,/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 1/tmp856oniiz.json,,,2022-12-16 14:02:31.092866
|
4 |
+
/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/57843eb6-2d89-4dc8-b9d8-2df141adbeea,/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 1/tmp0oj7zte5.json,,,2022-12-16 14:02:32.574170
|
5 |
+
/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 0/45f9d195-37f2-44a4-b76a-7cc600807802,/home/sasha/Documents/HuggingFace/find-my-butterfly/gradio_cached_examples/12/component 1/tmp93ewyfy8.json,,,2022-12-16 14:02:34.134232
|
lsh.pickle
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:caa1727832f2279a4026b03b9f17638ff4a4deffa0a28586e74db59332dce732
|
3 |
-
size 136667
|
|
|
|
|
|
|
|