mdanish commited on
Commit
10e00e5
·
verified ·
1 Parent(s): a541289

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -2,7 +2,7 @@ import streamlit as st
2
  from PIL import Image
3
  import numpy as np
4
  import torch
5
-
6
  import open_clip
7
 
8
  #from transformers import CLIPProcessor, CLIPModel
@@ -54,7 +54,7 @@ def knn_get_score(knn, k, cat, vec):
54
  cos_sim_table = vec @ allvecs.T
55
  if debug: st.write('cos_sim_table.shape', cos_sim_table.shape)
56
  # Get sorted array indices by similiarity in descending order
57
- sortinds = np.flip(np.argsort(cos_sim_table))
58
  if debug: st.write('sortinds.shape', sortinds.shape)
59
  # Get corresponding scores for the sorted vectors
60
  kscores = scores[sortinds][:k]
 
2
  from PIL import Image
3
  import numpy as np
4
  import torch
5
+ from sklearn.utils.extmath import softmax
6
  import open_clip
7
 
8
  #from transformers import CLIPProcessor, CLIPModel
 
54
  cos_sim_table = vec @ allvecs.T
55
  if debug: st.write('cos_sim_table.shape', cos_sim_table.shape)
56
  # Get sorted array indices by similiarity in descending order
57
+ sortinds = np.flip(np.argsort(cos_sim_table, axis=1), axis=1)
58
  if debug: st.write('sortinds.shape', sortinds.shape)
59
  # Get corresponding scores for the sorted vectors
60
  kscores = scores[sortinds][:k]