Spaces:
Runtime error
Runtime error
sashavor
commited on
Commit
·
1fbc5c6
1
Parent(s):
0c9c8ed
adding captions and examples
Browse files- app.py +6 -6
- elton.jpg +0 -0
- gaga.jpg +0 -0
- ken.jpg +0 -0
- taylor.jpg +0 -0
app.py
CHANGED
|
@@ -27,20 +27,20 @@ def query(image, top_k=4):
|
|
| 27 |
results = index.query(embedding, k=top_k)
|
| 28 |
inx = results[0][0].tolist()
|
| 29 |
images = ds.select(inx)["image"]
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
|
| 32 |
|
| 33 |
title = "Find my Butterfly 🦋"
|
| 34 |
-
description = "
|
|
|
|
| 35 |
|
| 36 |
-
# You can set the type of gr.Image to be PIL, numpy or str (filepath)
|
| 37 |
-
# Not sure what the best for this demo is.
|
| 38 |
gr.Interface(
|
| 39 |
query,
|
| 40 |
inputs=[gr.Image(type="pil")],
|
| 41 |
outputs=gr.Gallery().style(grid=[2], height="auto"),
|
| 42 |
-
# Filenames denote the integer labels. Know here: https://hf.co/datasets/beans
|
| 43 |
title=title,
|
| 44 |
description=description,
|
| 45 |
-
|
| 46 |
).launch()
|
|
|
|
| 27 |
results = index.query(embedding, k=top_k)
|
| 28 |
inx = results[0][0].tolist()
|
| 29 |
images = ds.select(inx)["image"]
|
| 30 |
+
captions = ds.select(inx)["name"]
|
| 31 |
+
images_with_captions = [(i, c) for i, c in zip(images,captions)]
|
| 32 |
+
return images_with_captions
|
| 33 |
|
| 34 |
|
| 35 |
title = "Find my Butterfly 🦋"
|
| 36 |
+
description = "Use this Space to find your butterfly, based on the [iNaturalist butterfly dataset](https://huggingface.co/datasets/huggan/inat_butterflies_top10k)!"
|
| 37 |
+
|
| 38 |
|
|
|
|
|
|
|
| 39 |
gr.Interface(
|
| 40 |
query,
|
| 41 |
inputs=[gr.Image(type="pil")],
|
| 42 |
outputs=gr.Gallery().style(grid=[2], height="auto"),
|
|
|
|
| 43 |
title=title,
|
| 44 |
description=description,
|
| 45 |
+
examples=[["elton.jpg"],["ken.jpg"],["gaga.jpg"],["taylor.jpg"]],
|
| 46 |
).launch()
|
elton.jpg
ADDED
|
gaga.jpg
ADDED
|
ken.jpg
ADDED
|
taylor.jpg
ADDED
|