Abhishek Thakur
commited on
Commit
·
8dacb08
1
Parent(s):
74236d8
map
Browse files- competitions/create.py +18 -14
- competitions/utils.py +0 -1
competitions/create.py
CHANGED
@@ -10,7 +10,7 @@ from . import BOT_TOKEN
|
|
10 |
from .utils import user_authentication
|
11 |
|
12 |
|
13 |
-
def verify_sample_and_solution(sample_submission, solution):
|
14 |
sample_submission = pd.read_csv(sample_submission.name)
|
15 |
solution = pd.read_csv(solution.name)
|
16 |
|
@@ -21,13 +21,14 @@ def verify_sample_and_solution(sample_submission, solution):
|
|
21 |
if "id" not in solution.columns:
|
22 |
raise Exception("Solution file should contain an id column")
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
|
32 |
# check if solution contains a split column
|
33 |
if "split" not in solution.columns:
|
@@ -41,11 +42,12 @@ def verify_sample_and_solution(sample_submission, solution):
|
|
41 |
if not set(solution["split"].unique()) == set(["public", "private"]):
|
42 |
raise Exception("Split column should contain only two unique values: public and private")
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
49 |
|
50 |
return True
|
51 |
|
@@ -66,7 +68,7 @@ def create_competition(
|
|
66 |
|
67 |
# verify sample submission and solution
|
68 |
try:
|
69 |
-
verify_sample_and_solution(sample_submission_file, solution_file)
|
70 |
except Exception as e:
|
71 |
return gr.Markdown.update(
|
72 |
value=f"""
|
@@ -122,6 +124,8 @@ def create_competition(
|
|
122 |
"SUBMISSION_ROWS": len(sample_submission_df),
|
123 |
"EVAL_METRIC": eval_metric,
|
124 |
}
|
|
|
|
|
125 |
|
126 |
api = HfApi()
|
127 |
|
@@ -431,7 +435,7 @@ with gr.Blocks() as demo:
|
|
431 |
placeholder="my-awesome-competition",
|
432 |
)
|
433 |
eval_metric = gr.Dropdown(
|
434 |
-
["accuracy", "auc", "f1", "logloss", "precision", "recall"],
|
435 |
label="Evaluation Metric",
|
436 |
value="accuracy",
|
437 |
)
|
|
|
10 |
from .utils import user_authentication
|
11 |
|
12 |
|
13 |
+
def verify_sample_and_solution(sample_submission, solution, eval_metric):
|
14 |
sample_submission = pd.read_csv(sample_submission.name)
|
15 |
solution = pd.read_csv(solution.name)
|
16 |
|
|
|
21 |
if "id" not in solution.columns:
|
22 |
raise Exception("Solution file should contain an id column")
|
23 |
|
24 |
+
if eval_metric != "map-iou":
|
25 |
+
# check if both files have the same ids
|
26 |
+
if not (sample_submission["id"] == solution["id"]).all():
|
27 |
+
raise Exception("Sample submission and solution should have the same ids")
|
28 |
|
29 |
+
# check if both files have the same number of rows
|
30 |
+
if sample_submission.shape[0] != solution.shape[0]:
|
31 |
+
raise Exception("Sample submission and solution should have the same number of rows")
|
32 |
|
33 |
# check if solution contains a split column
|
34 |
if "split" not in solution.columns:
|
|
|
42 |
if not set(solution["split"].unique()) == set(["public", "private"]):
|
43 |
raise Exception("Split column should contain only two unique values: public and private")
|
44 |
|
45 |
+
if eval_metric != "map-iou":
|
46 |
+
# except the `split` column, all other columns should be the same
|
47 |
+
solution_columns = solution.columns.tolist()
|
48 |
+
solution_columns.remove("split")
|
49 |
+
if not (sample_submission.columns == solution_columns).all():
|
50 |
+
raise Exception("Sample submission and solution should have the same columns, except for the split column")
|
51 |
|
52 |
return True
|
53 |
|
|
|
68 |
|
69 |
# verify sample submission and solution
|
70 |
try:
|
71 |
+
verify_sample_and_solution(sample_submission_file, solution_file, eval_metric)
|
72 |
except Exception as e:
|
73 |
return gr.Markdown.update(
|
74 |
value=f"""
|
|
|
124 |
"SUBMISSION_ROWS": len(sample_submission_df),
|
125 |
"EVAL_METRIC": eval_metric,
|
126 |
}
|
127 |
+
if eval_metric == "map-iou":
|
128 |
+
conf["IOU_THRESHOLD"] = 0.5
|
129 |
|
130 |
api = HfApi()
|
131 |
|
|
|
435 |
placeholder="my-awesome-competition",
|
436 |
)
|
437 |
eval_metric = gr.Dropdown(
|
438 |
+
["accuracy", "auc", "f1", "logloss", "map-iou", "precision", "recall"],
|
439 |
label="Evaluation Metric",
|
440 |
value="accuracy",
|
441 |
)
|
competitions/utils.py
CHANGED
@@ -16,7 +16,6 @@ def http_post(path: str, token: str, payload=None, domain: str = None, params=No
|
|
16 |
)
|
17 |
except requests.exceptions.ConnectionError:
|
18 |
logger.error("❌ Failed to reach AutoNLP API, check your internet connection")
|
19 |
-
logger.info(response.text)
|
20 |
response.raise_for_status()
|
21 |
return response
|
22 |
|
|
|
16 |
)
|
17 |
except requests.exceptions.ConnectionError:
|
18 |
logger.error("❌ Failed to reach AutoNLP API, check your internet connection")
|
|
|
19 |
response.raise_for_status()
|
20 |
return response
|
21 |
|