Spaces:
Runtime error
Runtime error
Add cosine sim
Browse files- __pycache__/app.cpython-39.pyc +0 -0
- 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 |
-
|
|
|
|
|
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 = [
|