SushantGautam commited on
Commit
1592511
Β·
1 Parent(s): ab0aa92

init task 1

Browse files
medvqa/cli.py CHANGED
@@ -10,15 +10,7 @@ If it still cannot solve the problem, don't hesitate to add an issue at https://
10
  ⚠️⚠️⚠️'''
11
 
12
 
13
- def main():
14
- parser = argparse.ArgumentParser(
15
- description='MedVQA CLI', allow_abbrev=False)
16
- parser.add_argument('--competition', type=str, required=True,
17
- help='Name of the competition (e.g., gi-2025)')
18
- parser.add_argument('--task', type=str, required=True,
19
- help='Task number (1 or 2)')
20
- args, unknown = parser.parse_known_args()
21
-
22
  # Dynamically find the base directory of the MedVQA library
23
  base_dir = os.path.dirname(os.path.abspath(__file__))
24
 
@@ -32,9 +24,32 @@ def main():
32
  if not os.path.isfile(task_file):
33
  raise FileNotFoundError(
34
  f"Task '{args.task}' does not exist! Need to update library?"+report)
35
- subprocess.run(
36
- ['python', task_file] + unknown)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
 
39
- if __name__ == '__main__':
40
  main()
 
10
  ⚠️⚠️⚠️'''
11
 
12
 
13
+ def validate(args, unk_args, submit=False):
 
 
 
 
 
 
 
 
14
  # Dynamically find the base directory of the MedVQA library
15
  base_dir = os.path.dirname(os.path.abspath(__file__))
16
 
 
24
  if not os.path.isfile(task_file):
25
  raise FileNotFoundError(
26
  f"Task '{args.task}' does not exist! Need to update library?"+report)
27
+ if submit:
28
+ subprocess.run(['python', task_file] + unk_args,
29
+ env={**os.environ, "_MEDVQA_SUBMIT_FLAG_": "TRUE"})
30
+ else:
31
+ subprocess.run(
32
+ ['python', task_file] + unk_args)
33
+
34
+
35
+ def main():
36
+ parser = argparse.ArgumentParser(description='MedVQA CLI')
37
+ subparsers = parser.add_subparsers(
38
+ dest='command', required=True, help="Either 'validate' or 'validate_and_submit'")
39
+
40
+ for cmd in ['validate', 'validate_and_submit']:
41
+ subparser = subparsers.add_parser(cmd)
42
+ subparser.add_argument(
43
+ '--competition', required=True, help='Name of the competition (e.g., gi-2025)')
44
+ subparser.add_argument('--task', required=True,
45
+ help='Task number (1 or 2)')
46
+
47
+ args, _unk_args = parser.parse_known_args()
48
+ if args.command == 'validate':
49
+ validate(args, _unk_args)
50
+ else:
51
+ validate(args, _unk_args, submit=True)
52
 
53
 
54
+ if __name__ == "__main__":
55
  main()
medvqa/competitions/gi-2025/task_1.py CHANGED
@@ -1,19 +1,51 @@
 
1
  import sys
2
  import argparse
 
 
3
 
4
 
5
- def main(repo, verbose=False):
6
- print("🌟 ImageCLEFmed-MEDVQA-GI-2025 🌟",
7
- "https://github.com/simula/ImageCLEFmed-MEDVQA-GI-2025")
8
- print("πŸ” Subtask 1: Algorithm Development for Question Interpretation and Response")
9
- print(f"Analyzing submission repository: {repo}")
10
- if verbose:
11
- print("Verbose mode is enabled")
12
 
 
 
 
13
 
14
- if __name__ == '__main__':
15
- parser = argparse.ArgumentParser(description='Run GI-1015 Task 1 (VQA)')
16
- parser.add_argument('--submission_repo', type=str, required=True,
17
- help='Path to the HF submission repository')
18
- args, _ = parser.parse_known_args()
19
- main(args.submission_repo)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import snapshot_download, login, whoami
2
  import sys
3
  import argparse
4
+ import os
5
+ import subprocess as sp
6
 
7
 
8
+ MEDVQA_SUBMIT = True if os.environ.get(
9
+ '_MEDVQA_SUBMIT_FLAG_', 'FALSE') == 'TRUE' else False
10
+ parser = argparse.ArgumentParser(description='Run GI-1015 Task 1 (VQA)')
11
+ parser.add_argument('--repo_id', type=str, required=True,
12
+ help='Path to the HF submission repository')
13
+ args, _ = parser.parse_known_args()
 
14
 
15
+ os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
16
+ submission_file = "submission_task1.py"
17
+ min_library = ["datasets", "transformers"]
18
 
19
+ print("🌟 ImageCLEFmed-MEDVQA-GI-2025 🌟",
20
+ "https://github.com/simula/ImageCLEFmed-MEDVQA-GI-2025")
21
+ print("πŸ” Subtask 1: Algorithm Development for Question Interpretation and Response")
22
+ print(f"πŸ‘€ Analyzing submission repository: {args.repo_id} πŸ‘€")
23
+
24
+ try:
25
+ print(f"Logged in as: {whoami()['name']}")
26
+ except Exception:
27
+ print("⚠️⚠️ Not logged in to HuggingFace! Please get your login token from https://huggingface.co/settings/tokens 🌐")
28
+ login()
29
+
30
+ snap_dir = snapshot_download(
31
+ repo_id=args.repo_id, allow_patterns=[submission_file, "requirements.txt"])
32
+
33
+ if not os.path.isfile(os.path.join(snap_dir, submission_file)):
34
+ raise FileNotFoundError(
35
+ f"Submission file '{submission_file}' not found in the repository!")
36
+
37
+ print("πŸ“¦ Making sure of the minimum requirements to run the script πŸ“¦")
38
+ sp.run(["python", "-m", "pip", "install"] + min_library, check=True)
39
+
40
+ if os.path.isfile(os.path.join(snap_dir, "requirements.txt")):
41
+ print(
42
+ f"πŸ“¦ Installing requirements from the submission repo: {args.repo_id}/requirements.txt")
43
+ sp.run(["python", "-m", "pip", "install", "-r",
44
+ f"{snap_dir}/requirements.txt"], cwd=snap_dir, check=True)
45
+
46
+ sp.run(["python", f"{snap_dir}/{submission_file}"],
47
+ cwd=snap_dir, check=True)
48
+
49
+ breakpoint()
50
+ if MEDVQA_SUBMIT:
51
+ print("πŸš€ Preparing for submission πŸš€")
pyproject.toml CHANGED
@@ -5,7 +5,8 @@ description = "Competition Submission CLI for ImageCLEFmed-MedVQA-GI-2025 (https
5
  readme = "README.md"
6
  requires-python = ">=3.6"
7
  dependencies = [
8
- # Add your dependencies here
 
9
  ]
10
  authors = [
11
  { name="Sushant Gautam", email="[email protected]" },
 
5
  readme = "README.md"
6
  requires-python = ">=3.6"
7
  dependencies = [
8
+ "huggingface_hub",
9
+ "huggingface_hub[hf_transfer]",
10
  ]
11
  authors = [
12
  { name="Sushant Gautam", email="[email protected]" },