sashavor commited on
Commit
8fd2365
1 Parent(s): 0d69242

adding captions and examples

Browse files
Files changed (5) hide show
  1. app.py +6 -6
  2. elton.jpg +0 -0
  3. gaga.jpg +0 -0
  4. ken.jpg +0 -0
  5. 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
- return images
 
 
31
 
32
 
33
  title = "Find my Butterfly 🦋"
34
- description = "This Space demos an image similarity system. You can refer to [this notebook](TODO) to know the details of the system. You can pick any image from the available samples below. On the right hand side, you'll find the similar images returned by the system. The example images have been named with their corresponding integer class labels for easier identification. The fetched images will also have their integer labels tagged so that you can validate the correctness of the results."
 
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
- #examples=[["0.png", 5], ["1.png", 5], ["2.png", 5]],
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