amanmibra commited on
Commit
0cda13e
1 Parent(s): 461f079

Add cosine sim

Browse files
Files changed (2) hide show
  1. __pycache__/app.cpython-39.pyc +0 -0
  2. app.py +3 -1
__pycache__/app.cpython-39.pyc ADDED
Binary file (2.1 kB). View file
 
app.py CHANGED
@@ -31,7 +31,9 @@ def compare(path1, path2):
31
  # return OUTPUT_OK.format(similarity_score * 100)
32
  # else:
33
  # return OUTPUT_FAIL.format(similarity_score * 100)
34
- return "{:.4f}".format(similarity_score.item())
 
 
35
 
36
 
37
  inputs = [
 
31
  # return OUTPUT_OK.format(similarity_score * 100)
32
  # else:
33
  # return OUTPUT_FAIL.format(similarity_score * 100)
34
+ cosine_sim = torch.nn.CosineSimilarity(dim=-1)
35
+ cosine_similiarity = cosine_sim(embs1, embs2)
36
+ return "Calulated Score: {:.2f}\nCosineSimilarity: {:.4f}".format(similarity_score.item() * 100, cosine_similiarity)
37
 
38
 
39
  inputs = [