def setUpClass(cls): cls.templates_folder = os.environ['MODEL_TEMPLATES'] cls.template_folder = os.path.join(cls.templates_folder, domain_name, problem_name, model_name) skip_non_instantiated_template_if_its_allowed( cls.template_folder, problem_name, model_name) cls.template_file = os.path.join(cls.template_folder, 'template.yaml') cls.ann_file = ann_file cls.img_root = img_root cls.dependencies = get_dependencies(cls.template_file) cls.epochs_delta = 1 cls.total_epochs = get_epochs(cls.template_file) + cls.epochs_delta expected_outputs_json = f'{expected_outputs_dir}/{problem_name}/{model_name}.json' with open(expected_outputs_json) as read_file: cls.expected_outputs = json.load(read_file) download_snapshot_if_not_yet(cls.template_file, cls.template_folder) run_through_shell(f'cd {cls.template_folder};' f'pip install -r requirements.txt;')
def setUpClass(cls): cls.compress_cmd_line_params = compress_cmd_line_params cls.test_case_description = cls.generate_test_case_description( template_update_dict, compress_cmd_line_params, compression_cfg_update_dict) logging.info(f'Begin setting up class for {problem_name}/{model_name}, {cls.test_case_description}') cls.templates_folder = os.environ['MODEL_TEMPLATES'] cls.src_template_folder = os.path.join(cls.templates_folder,domain_name, problem_name, model_name) skip_non_instantiated_template_if_its_allowed(cls.src_template_folder, problem_name, model_name) src_template_file = os.path.join(cls.src_template_folder, 'template.yaml') download_snapshot_if_not_yet(src_template_file, cls.src_template_folder) cls.template_folder = cls.generate_template_folder_name(cls.src_template_folder, cls.test_case_description) cls.copy_template_folder(cls.src_template_folder, cls.template_folder) cls.template_file = os.path.join(cls.template_folder, 'template.yaml') cls.apply_update_dict_params_to_template_file(cls.template_file, template_update_dict, compression_cfg_update_dict) cls.ann_file = ann_file cls.img_root = img_root cls.dependencies = get_dependencies(cls.template_file) download_snapshot_if_not_yet(cls.template_file, cls.template_folder) run_through_shell( f'cd {cls.template_folder};' ) logging.info(f'End setting up class for {problem_name}/{model_name}, {cls.test_case_description}')
def setUpClass(cls): cls.templates_folder = os.environ['MODEL_TEMPLATES'] cls.template_folder = os.path.join(cls.templates_folder, 'instance_segmentation_2', problem_name, model_name) cls.template_file = os.path.join(cls.template_folder, 'template.yaml') cls.ann_file = ann_file cls.img_root = img_root cls.dependencies = get_dependencies(cls.template_file) cls.epochs_delta = 2 cls.total_epochs = get_epochs(cls.template_file) + cls.epochs_delta download_snapshot_if_not_yet(cls.template_file, cls.template_folder) coco_dir = os.path.abspath( f'{os.path.dirname(__file__)}/../../../../data/coco') val_dir = os.path.join(coco_dir, 'val2017') zip_file = os.path.join(coco_dir, 'val2017.zip') link = 'http://images.cocodataset.org/zips/val2017.zip' if not os.path.exists(val_dir): if not os.path.exists(zip_file): run_through_shell( f'wget --no-verbose {link} -P {coco_dir}') run_through_shell(f'unzip {zip_file} -d {coco_dir}') run_through_shell(f'cd {cls.template_folder};' f'pip install -r requirements.txt;')
def main(): args = parse_args() log_level = logging.DEBUG if args.verbose else logging.INFO logging.basicConfig(level=log_level) with open(args.template) as read_file: content = yaml.load(read_file, yaml.SafeLoader) os.makedirs(args.output, exist_ok=True) run_through_shell( f'cp -r {os.path.dirname(args.template)}/* --target-directory={args.output}', verbose=args.verbose) for dependency in content['dependencies']: source = dependency['source'] destination = dependency['destination'] if destination != 'snapshot.pth': rel_source = os.path.join(os.path.dirname(args.template), source) cur_dst = os.path.join(args.output, destination) os.makedirs(os.path.dirname(cur_dst), exist_ok=True) run_through_shell( f'cp -r --no-target-directory {rel_source} {cur_dst}', check=True, verbose=args.verbose) if not args.do_not_load_snapshot: download_snapshot_if_not_yet(args.template, args.output)
def setUpClass(cls): cls.templates_folder = os.environ['MODEL_TEMPLATES'] cls.template_folder = os.path.join(cls.templates_folder, 'action_recognition_2', problem_name, model_name) cls.template_file = os.path.join(cls.template_folder, 'template.yaml') cls.ann_file = ann_file cls.img_root = img_root cls.dependencies = get_dependencies(cls.template_file) download_snapshot_if_not_yet(cls.template_file, cls.template_folder) run_through_shell( f'cd {cls.template_folder};' f'pip install -r requirements.txt;' )
def setUpClass(cls): cls.templates_folder = os.environ['MODEL_TEMPLATES'] cls.template_folder = os.path.join(cls.templates_folder, domain_name, problem_name, model_name) skip_non_instantiated_template_if_its_allowed(cls.template_folder, problem_name, model_name) cls.template_file = os.path.join(cls.template_folder, 'template.yaml') cls.ann_file = ann_file cls.img_root = img_root cls.dependencies = get_dependencies(cls.template_file) cls.test_export_thr = 3.5 expected_outputs_json = f'{expected_outputs_dir}/{problem_name}/{model_name}.json' with open(expected_outputs_json) as read_file: cls.expected_outputs = json.load(read_file) download_snapshot_if_not_yet(cls.template_file, cls.template_folder)
def setUpClass(cls): cls.templates_folder = os.environ['MODEL_TEMPLATES'] cls.template_folder = os.path.join(cls.templates_folder, 'object_detection', problem_name, model_name) skip_non_instantiated_template_if_its_allowed( cls.template_folder, problem_name, model_name) cls.template_file = os.path.join(cls.template_folder, 'template.yaml') cls.ann_file = ann_file cls.img_root = img_root cls.dependencies = get_dependencies(cls.template_file) cls.test_export_thr = 0.031 download_snapshot_if_not_yet(cls.template_file, cls.template_folder)
def setUpClass(cls): cls.template_updates_description = cls.generate_template_updates_description( template_update_dict) logging.info( f'Begin setting up class for {problem_name}/{model_name}, {cls.template_updates_description}' ) cls.templates_folder = os.environ['MODEL_TEMPLATES'] cls.src_template_folder = os.path.join(cls.templates_folder, 'object_detection', problem_name, model_name) skip_non_instantiated_template_if_its_allowed( cls.src_template_folder, problem_name, model_name) cls.template_folder = cls.generate_template_folder_name( cls.src_template_folder, cls.template_updates_description) cls.copy_template_folder(cls.src_template_folder, cls.template_folder) cls.template_file = os.path.join(cls.template_folder, 'template.yaml') cls.apply_update_dict_params_to_template_file( cls.template_file, template_update_dict, compression_cfg_update_dict) cls.ann_file = ann_file cls.img_root = img_root cls.dependencies = get_dependencies(cls.template_file) # Note that such big threshold is required, since # we have very small dataset for training and evaluation: # if network compression causes other detections # on 2-4 images, the accuracy drop will be significant. cls.test_export_thr = 0.05 download_snapshot_if_not_yet(cls.template_file, cls.template_folder) run_through_shell(f'cd {cls.template_folder};' f'pip install -r requirements.txt;') logging.info( f'End setting up class for {problem_name}/{model_name}, {cls.template_updates_description}' )
def setUpClass(cls): cls.templates_folder = os.environ['MODEL_TEMPLATES'] cls.template_folder = os.path.join(cls.templates_folder, 'object_detection', problem_name, model_name) skip_non_instantiated_template_if_its_allowed( cls.template_folder, problem_name, model_name) cls.template_file = os.path.join(cls.template_folder, 'template.yaml') cls.ann_file = ann_file cls.img_root = img_root cls.dependencies = get_dependencies(cls.template_file) cls.epochs_delta = 2 cls.total_epochs = get_epochs(cls.template_file) + cls.epochs_delta download_snapshot_if_not_yet(cls.template_file, cls.template_folder) run_through_shell(f'cd {cls.template_folder};' f'pip install -r requirements.txt;')
def main(): logging.basicConfig(level=logging.INFO) args = parse_args() with open(args.template) as read_file: content = yaml.load(read_file, yaml.SafeLoader) os.makedirs(args.output, exist_ok=True) os.system(f'cp -r {os.path.dirname(args.template)}/* {args.output}') for dependency in content['dependencies']: source = dependency['source'] destination = dependency['destination'] if destination != 'snapshot.pth': rel_source = os.path.join(os.path.dirname(args.template), source) os.makedirs(os.path.dirname(os.path.join(args.output, destination)), exist_ok=True) run(f'cp -r {rel_source} {os.path.join(args.output, destination)}', check=True, shell=True) if not args.do_not_load_snapshot: download_snapshot_if_not_yet(args.template, args.output)