mdanish commited on
Commit
b26dae6
·
verified ·
1 Parent(s): fabd799

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +3 -0
app.py CHANGED
@@ -50,13 +50,16 @@ def process_image(image, preprocess):
50
 
51
  def knn_get_score(knn, k, cat, vec):
52
  allvecs = knn[f'{cat}_vecs']
 
53
  scores = knn[f'{cat}_scores']
 
54
  # Compute cosine similiarity of vec against allvecs
55
  # (both are already normalized)
56
  cos_sim_table = vec @ allvecs.T
57
  st.write('cos_sim_table.shape', cos_sim_table.shape)
58
  # Get sorted array indices by similiarity in descending order
59
  sortinds = np.flip(np.argsort(cos_sim_table))
 
60
  # Get corresponding scores for the sorted vectors
61
  kscores = scores[sortinds][:k]
62
  st.write('kscores.shape', kscores.shape)
 
50
 
51
  def knn_get_score(knn, k, cat, vec):
52
  allvecs = knn[f'{cat}_vecs']
53
+ st.write('allvecs.shape', allvecs.shape)
54
  scores = knn[f'{cat}_scores']
55
+ st.write('scores.shape', scores.shape)
56
  # Compute cosine similiarity of vec against allvecs
57
  # (both are already normalized)
58
  cos_sim_table = vec @ allvecs.T
59
  st.write('cos_sim_table.shape', cos_sim_table.shape)
60
  # Get sorted array indices by similiarity in descending order
61
  sortinds = np.flip(np.argsort(cos_sim_table))
62
+ st.write('sortinds.shape', sortinds.shape)
63
  # Get corresponding scores for the sorted vectors
64
  kscores = scores[sortinds][:k]
65
  st.write('kscores.shape', kscores.shape)