Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -64,6 +64,18 @@ def get_result_df():
|
|
| 64 |
df = pd.read_csv(CSV_DIR)[COLUMN_NAMES]
|
| 65 |
df = df.sort_values(by=AVGACC, ascending=False)
|
| 66 |
return df
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
def prediction_analyse(prediction_content,questiontype_list):
|
| 68 |
predictions = prediction_content.split("\n")
|
| 69 |
|
|
@@ -128,6 +140,8 @@ def add_new_eval(
|
|
| 128 |
):
|
| 129 |
if len(model_name_textbox) == 0:
|
| 130 |
return "Error! Empty model name!", get_result_df()
|
|
|
|
|
|
|
| 131 |
|
| 132 |
if input_file is None:
|
| 133 |
return "Error! Empty file!", get_result_df()
|
|
@@ -144,7 +158,9 @@ def add_new_eval(
|
|
| 144 |
userdata = content.split('\n')
|
| 145 |
if len(userdata) != count_lines(GT_PATH):
|
| 146 |
return f"Error! The number of lines in the submit file ({len(userdata)}) does not match the number of lines in the AUTO-EVAL-VIDEO.json file ({count_lines(GT_PATH)}).", get_result_df()
|
| 147 |
-
|
|
|
|
|
|
|
| 148 |
prediction = prediction_analyse(content,questiontype)
|
| 149 |
|
| 150 |
each_task_accuracy = {i: round(prediction[i]["correct"] / max(1, prediction[i]["total"]) * 100, 1) for i in questiontype}
|
|
|
|
| 64 |
df = pd.read_csv(CSV_DIR)[COLUMN_NAMES]
|
| 65 |
df = df.sort_values(by=AVGACC, ascending=False)
|
| 66 |
return df
|
| 67 |
+
|
| 68 |
+
def check_json(prediction_content):
|
| 69 |
+
|
| 70 |
+
predictions = prediction_content.split("\n")
|
| 71 |
+
for prediction in predictions:
|
| 72 |
+
try:
|
| 73 |
+
prediction = json.loads(prediction)
|
| 74 |
+
except json.JSONDecodeError:
|
| 75 |
+
print(f"Warning: Skipping invalid JSON data in line: {prediction}")
|
| 76 |
+
return False
|
| 77 |
+
return True
|
| 78 |
+
|
| 79 |
def prediction_analyse(prediction_content,questiontype_list):
|
| 80 |
predictions = prediction_content.split("\n")
|
| 81 |
|
|
|
|
| 140 |
):
|
| 141 |
if len(model_name_textbox) == 0:
|
| 142 |
return "Error! Empty model name!", get_result_df()
|
| 143 |
+
if len(model_link) == 0:
|
| 144 |
+
return "Error! Empty model link!", get_result_df()
|
| 145 |
|
| 146 |
if input_file is None:
|
| 147 |
return "Error! Empty file!", get_result_df()
|
|
|
|
| 158 |
userdata = content.split('\n')
|
| 159 |
if len(userdata) != count_lines(GT_PATH):
|
| 160 |
return f"Error! The number of lines in the submit file ({len(userdata)}) does not match the number of lines in the AUTO-EVAL-VIDEO.json file ({count_lines(GT_PATH)}).", get_result_df()
|
| 161 |
+
if not check_json(content):
|
| 162 |
+
return "JSON DECODE ERROR!", get_result_df()
|
| 163 |
+
|
| 164 |
prediction = prediction_analyse(content,questiontype)
|
| 165 |
|
| 166 |
each_task_accuracy = {i: round(prediction[i]["correct"] / max(1, prediction[i]["total"]) * 100, 1) for i in questiontype}
|