File size: 2,553 Bytes
64e0d0d 2dcbc67 ab0aa92 2dcbc67 64e0d0d be00b48 438bec4 64e0d0d 2dcbc67 438bec4 2dcbc67 1bf71b8 2dcbc67 7aa3345 2dcbc67 438bec4 1bf71b8 1592511 be00b48 1592511 be00b48 1592511 be00b48 1592511 be00b48 1592511 be00b48 64e0d0d 2dcbc67 1592511 64e0d0d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
import argparse
import subprocess
import os
report = '''\n⚠️⚠️⚠️\n
Try installing latest version of the library by running the following command:
pip install -u medvqa
If it still cannot solve the problem, don't hesitate to add an issue at https://github.com/SushantGautam/MedVQA/issues with the log above! We will try to solve the problem ASAP. Can also interact with us on Discord: https://discord.gg/22V9huwc3R.\n
⚠️⚠️⚠️'''
def validate(args, unk_args, submit=False, challenge_evaluate=False):
# Dynamically find the base directory of the MedVQA library
base_dir = os.path.dirname(os.path.abspath(__file__))
# Check if competition directory exists
competition_dir = os.path.join(base_dir, 'competitions', args.competition)
if not os.path.isdir(competition_dir):
raise FileNotFoundError(
f"Competition '{args.competition}' does not exist! Need to update library?"+report)
# Check if task file exists
task_file = os.path.join(competition_dir, f'task_{args.task}.py')
if not os.path.isfile(task_file):
raise FileNotFoundError(
f"Task '{args.task}' does not exist! Need to update library?"+report)
if submit:
subprocess.run(['python', task_file] + unk_args,
env={**os.environ, "_MEDVQA_SUBMIT_FLAG_": "TRUE"})
elif challenge_evaluate:
subprocess.run(['python', task_file] + unk_args,
env={**os.environ, "_MEDVQA_CHALLENGE_EVALUATE_FLAG_": "TRUE"})
else:
subprocess.run(
['python', task_file] + unk_args)
def main():
parser = argparse.ArgumentParser(description='MedVQA CLI')
subparsers = parser.add_subparsers(
dest='command', required=True, help="Either 'validate', 'validate_and_submit', or 'challenge_evaluate'")
for cmd in ['validate', 'validate_and_submit', 'challenge_evaluate']:
subparser = subparsers.add_parser(cmd)
subparser.add_argument(
'--competition', required=True, help='Name of the competition (e.g., gi-2025)')
subparser.add_argument('--task', required=True,
help='Task number (1 or 2)')
args, _unk_args = parser.parse_known_args()
if args.command == 'validate':
validate(args, _unk_args)
elif args.command == 'validate_and_submit':
validate(args, _unk_args, submit=True)
elif args.command == 'challenge_evaluate':
validate(args, _unk_args, challenge_evaluate=True)
if __name__ == "__main__":
main()
|