Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -165,7 +165,7 @@ def main(json_file):
|
|
| 165 |
|
| 166 |
# %%
|
| 167 |
### Compute scores
|
| 168 |
-
|
| 169 |
result_direct = get_score_direct(random_sample_pair_test_direct, predictions, key_pair, similarity_score_test_direct, k = 200)
|
| 170 |
result_indirect = get_score_indirect(random_sample_pair_test_indirect, predictions, key_pair, similarity_score_test_indirect, k = 200)
|
| 171 |
result_dict = {**result_direct, **result_indirect}
|
|
@@ -182,21 +182,26 @@ if __name__ == '__main__':
|
|
| 182 |
json_file = None
|
| 183 |
|
| 184 |
uploaded_files = st.file_uploader("Upload All Result Files Here (results_pair_dict1.json, results_pair_dict2.json)", type=["csv"], accept_multiple_files=True)
|
| 185 |
-
|
| 186 |
-
json_file1 = load_json(os.path.join(os.environ['ROOT'], 'results_pair_dict1.json'))
|
| 187 |
-
json_file2 = load_json(os.path.join(os.environ['ROOT'], 'results_pair_dict2.json'))
|
| 188 |
-
json_file = {**json_file1, **json_file2}
|
| 189 |
dataframe = pd.DataFrame([])
|
| 190 |
-
if uploaded_files
|
|
|
|
| 191 |
for i in range(len(uploaded_files)):
|
| 192 |
dataframe = pd.concat([dataframe, pd.read_csv(uploaded_files[i])])
|
| 193 |
-
|
| 194 |
result = dataframe.to_dict('tight')['data']
|
| 195 |
json_file = {}
|
| 196 |
for i in range(len(result)):
|
| 197 |
json_file[str(result[i][1])] = float(result[i][2])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
|
| 199 |
if len(json_file) >= 1:
|
|
|
|
| 200 |
result_dict = main(json_file)
|
| 201 |
result_text = json.dumps(result_dict)
|
| 202 |
|
|
|
|
| 165 |
|
| 166 |
# %%
|
| 167 |
### Compute scores
|
| 168 |
+
print("computing the score !!")
|
| 169 |
result_direct = get_score_direct(random_sample_pair_test_direct, predictions, key_pair, similarity_score_test_direct, k = 200)
|
| 170 |
result_indirect = get_score_indirect(random_sample_pair_test_indirect, predictions, key_pair, similarity_score_test_indirect, k = 200)
|
| 171 |
result_dict = {**result_direct, **result_indirect}
|
|
|
|
| 182 |
json_file = None
|
| 183 |
|
| 184 |
uploaded_files = st.file_uploader("Upload All Result Files Here (results_pair_dict1.json, results_pair_dict2.json)", type=["csv"], accept_multiple_files=True)
|
| 185 |
+
|
|
|
|
|
|
|
|
|
|
| 186 |
dataframe = pd.DataFrame([])
|
| 187 |
+
if uploaded_files != None:
|
| 188 |
+
print("upload file process")
|
| 189 |
for i in range(len(uploaded_files)):
|
| 190 |
dataframe = pd.concat([dataframe, pd.read_csv(uploaded_files[i])])
|
| 191 |
+
|
| 192 |
result = dataframe.to_dict('tight')['data']
|
| 193 |
json_file = {}
|
| 194 |
for i in range(len(result)):
|
| 195 |
json_file[str(result[i][1])] = float(result[i][2])
|
| 196 |
+
|
| 197 |
+
if st.button('Run Evaluation with no upload files (using demo files)'):
|
| 198 |
+
json_file1 = load_json(os.path.join(os.environ['ROOT'], 'results_pair_dict1.json'))
|
| 199 |
+
json_file2 = load_json(os.path.join(os.environ['ROOT'], 'results_pair_dict2.json'))
|
| 200 |
+
json_file = {**json_file1, **json_file2}
|
| 201 |
+
print("finished loading json")
|
| 202 |
|
| 203 |
if len(json_file) >= 1:
|
| 204 |
+
print("running evaluation")
|
| 205 |
result_dict = main(json_file)
|
| 206 |
result_text = json.dumps(result_dict)
|
| 207 |
|