Commit
·
b2065f5
1
Parent(s):
6a06073
add task 1 solution
Browse files
medvqa/competitions/gi-2025/task_1.py
CHANGED
@@ -8,6 +8,12 @@ import subprocess as sp
|
|
8 |
import time
|
9 |
from datetime import datetime, timezone
|
10 |
import shutil # Add this import
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
MEDVQA_SUBMIT = True if os.environ.get(
|
13 |
'_MEDVQA_SUBMIT_FLAG_', 'FALSE') == 'TRUE' else False
|
@@ -77,6 +83,26 @@ else:
|
|
77 |
snap_dir, f"{hf_username}-_-_-{current_timestamp}-_-_-task1.json")
|
78 |
shutil.copy(os.path.join(snap_dir, file_from_validation),
|
79 |
file_path_to_upload) # Use shutil.copy here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
result = client.predict(
|
81 |
file=handle_file(file_path_to_upload),
|
82 |
api_name="/add_submission"
|
|
|
8 |
import time
|
9 |
from datetime import datetime, timezone
|
10 |
import shutil # Add this import
|
11 |
+
import json
|
12 |
+
import os
|
13 |
+
from huggingface_hub import HfApi, grant_access
|
14 |
+
|
15 |
+
HF_GATE_ACESSLIST = ["[email protected]",
|
16 |
+
"[email protected]", "[email protected]"]
|
17 |
|
18 |
MEDVQA_SUBMIT = True if os.environ.get(
|
19 |
'_MEDVQA_SUBMIT_FLAG_', 'FALSE') == 'TRUE' else False
|
|
|
83 |
snap_dir, f"{hf_username}-_-_-{current_timestamp}-_-_-task1.json")
|
84 |
shutil.copy(os.path.join(snap_dir, file_from_validation),
|
85 |
file_path_to_upload) # Use shutil.copy here
|
86 |
+
# add repo_id to the submission file
|
87 |
+
with open(file_path_to_upload, 'r', encoding='utf-8') as f:
|
88 |
+
data = json.load(f)
|
89 |
+
data['repo_id'] = args.repo_id
|
90 |
+
with open(file_path_to_upload, 'w', encoding='utf-8') as f:
|
91 |
+
json.dump(data, f, ensure_ascii=False)
|
92 |
+
api = HfApi()
|
93 |
+
api.update_repo_visibility(args.repo_id, private=False) # Make public
|
94 |
+
api.update_repo_settings(args.repo_id, gated=True) # Enable gated access
|
95 |
+
|
96 |
+
for user in HF_GATE_ACESSLIST:
|
97 |
+
grant_access(args.repo_id, user) # Grant access
|
98 |
+
|
99 |
+
print(
|
100 |
+
f'''✅ {args.repo_id} model is now made public, but gated, and is shared with organizers.
|
101 |
+
You should not make the model private or remove/update it until the competition results are announced.
|
102 |
+
Feel feel to re-submit the task if you change the model on the repository.
|
103 |
+
We will notify you if there are any issues with the submission.
|
104 |
+
''')
|
105 |
+
|
106 |
result = client.predict(
|
107 |
file=handle_file(file_path_to_upload),
|
108 |
api_name="/add_submission"
|