gustproof commited on
Commit
006e560
1 Parent(s): 45be003

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -24,7 +24,7 @@ with open("urls.txt") as f:
24
  print("loaded urls")
25
  assert len(urls) == len(ys)
26
  d = ys.shape[1]
27
- index = faiss.IndexFlatL2(d)
28
  print("building index")
29
  index.add(ys)
30
  print('index built')
@@ -54,12 +54,12 @@ row_size = 5
54
 
55
  def f(im):
56
  D, I = index.search(get_emb(im), n_outputs)
57
- return [f"Distance: {d}\n![]({urls[i]})" for d, i in zip(D[0], I[0])]
58
 
59
  print("preparing gradio")
60
  with gr.Blocks() as demo:
61
  gr.Markdown(
62
- "# Style Similarity Search\n\nFind artworks with a similar style from a small database (10k artists * 6img/artist)"
63
  )
64
  img = gr.Image(type="pil", label="Query", height=500)
65
  btn = gr.Button(variant="primary", value="search")
 
24
  print("loaded urls")
25
  assert len(urls) == len(ys)
26
  d = ys.shape[1]
27
+ index = faiss.IndexHNSWFlat(d, 32)
28
  print("building index")
29
  index.add(ys)
30
  print('index built')
 
54
 
55
  def f(im):
56
  D, I = index.search(get_emb(im), n_outputs)
57
+ return [f"Distance: {d}\n![]({urls[i]}:.1f)" for d, i in zip(D[0], I[0])]
58
 
59
  print("preparing gradio")
60
  with gr.Blocks() as demo:
61
  gr.Markdown(
62
+ "# Style Similarity Search\n\nFind artworks with a similar style from a medium database (10k artists * 30 img/artist)"
63
  )
64
  img = gr.Image(type="pil", label="Query", height=500)
65
  btn = gr.Button(variant="primary", value="search")