def _extract_model(silent=False): """Extract model from Tensorflow model zoo. Args: silent (bool): if False, writes progress messages to stdout """ maybe_print(not silent, "Preparing pretrained model") model_dir = PATHS.get_models_dir_path() maybe_mkdir(model_dir) model_archive_path = PATHS.get_data_file_path( 'ssd_inception_v2_coco_2017_11_17.tar.gz') maybe_print(not silent, "Unpacking {}".format(model_archive_path)) with tarfile.open(model_archive_path, "r:gz") as tar: tar.extractall(path=model_dir) maybe_print(not silent, "Model ready")
def download_model(model_name, silent=False): """Downloads model_name from Tensorflow model zoo. Args: model_name (str): chosen object detection model silent (bool): if True, writes progress messages to stdout """ maybe_print(not silent, "Preparing pretrained model") model_dir = PATHS.get_models_dir_path() maybe_mkdir(model_dir) model_url = PATHS.get_model_url(model_name) model_archive_path = os.path.join(model_dir, "{}.tar.gz".format(model_name)) download_file(model_url, model_archive_path, silent) maybe_print(not silent, "Download complete\nUnpacking {}".format(model_archive_path)) with tarfile.open(model_archive_path, "r:gz") as tar: tar.extractall(path=model_dir) maybe_print(not silent, "Extracting complete\nRemoving {}".format(model_archive_path)) os.remove(model_archive_path) maybe_print(not silent, "Model ready")