Spaces:
Running
Running
Petra Vidnerova commited on
Commit ·
38bfbd5
1
Parent(s): 5642ff7
before sleep
Browse files
README.md
CHANGED
|
@@ -8,7 +8,7 @@ sdk_version: 6.5.1
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
-
short_description: simple app for the purpose of novelty
|
| 12 |
---
|
| 13 |
|
| 14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
+
short_description: simple app for the purpose of novelty challenge
|
| 12 |
---
|
| 13 |
|
| 14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
|
@@ -114,12 +114,15 @@ def process_id(id_number, session_id):
|
|
| 114 |
ref_embeddings = result
|
| 115 |
|
| 116 |
yield "Calculating the final score...", api_data_display, None, None
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
| 118 |
time.sleep(0.5)
|
| 119 |
|
| 120 |
result_message = f"🎉 Processing complete! Score calculated successfully."
|
| 121 |
|
| 122 |
-
yield result_message, api_data_display, score,
|
| 123 |
|
| 124 |
|
| 125 |
# Create Gradio interface
|
|
|
|
| 114 |
ref_embeddings = result
|
| 115 |
|
| 116 |
yield "Calculating the final score...", api_data_display, None, None
|
| 117 |
+
score1 = calculate_score(paper_embedding, ref_embeddings)
|
| 118 |
+
score2 = calculate_score(None, ref_embeddings)
|
| 119 |
+
score = (score1 * score2) / (score1 + score2)
|
| 120 |
+
normalized_score = (score - 0.01) / (0.1 - 0.01) # todo adjust min/max based on real data
|
| 121 |
time.sleep(0.5)
|
| 122 |
|
| 123 |
result_message = f"🎉 Processing complete! Score calculated successfully."
|
| 124 |
|
| 125 |
+
yield result_message, api_data_display, score, normalized_score
|
| 126 |
|
| 127 |
|
| 128 |
# Create Gradio interface
|
utils.py
CHANGED
|
@@ -80,6 +80,8 @@ def create_abstract(abstract_index):
|
|
| 80 |
def calculate_score(paper_embedding, ref_embeddings):
|
| 81 |
if ref_embeddings.shape[0] == 0:
|
| 82 |
return 0.0
|
|
|
|
|
|
|
| 83 |
similarities = torch.nn.functional.cosine_similarity(
|
| 84 |
paper_embedding,
|
| 85 |
ref_embeddings,
|
|
|
|
| 80 |
def calculate_score(paper_embedding, ref_embeddings):
|
| 81 |
if ref_embeddings.shape[0] == 0:
|
| 82 |
return 0.0
|
| 83 |
+
if paper_embedding is None:
|
| 84 |
+
paper_embedding = ref_embeddings.mean(axis=0).unsqueeze(0)
|
| 85 |
similarities = torch.nn.functional.cosine_similarity(
|
| 86 |
paper_embedding,
|
| 87 |
ref_embeddings,
|