def main(): """ Main body of script. """ args = parse_args() if args.disable_cudnn_autotune: os.environ["MXNET_CUDNN_AUTOTUNE_DEFAULT"] = "0" _, log_file_exist = initialize_logging( logging_dir_path=args.save_dir, logging_file_name=args.logging_file_name, script_args=args, log_packages=args.log_packages, log_pip_packages=args.log_pip_packages) if args.all: args.use_pretrained = True dataset_name_map = { "in1k": "ImageNet1K", "cub": "CUB200_2011", "cf10": "CIFAR10", "cf100": "CIFAR100", "svhn": "SVHN", "voc": "VOC", "ade20k": "ADE20K", "cs": "Cityscapes", "cocoseg": "CocoSeg", "cocohpe": "CocoHpe", "hp": "HPatches", } for model_name, model_metainfo in (_model_sha1.items() if version_info[0] >= 3 else _model_sha1.iteritems()): error, checksum, repo_release_tag, caption, paper, ds, img_size, scale, batch, rem = model_metainfo if (ds != "in1k") or (img_size == 0) or ((len(rem) > 0) and (rem[-1] == "*")): continue args.dataset = dataset_name_map[ds] args.model = model_name args.input_size = img_size args.resize_inv_factor = scale args.batch_size = batch logging.info("==============") logging.info("Checking model: {}".format(model_name)) acc_value = test_model(args=args) if acc_value is not None: exp_value = int(error) * 1e-4 if abs(acc_value - exp_value) > 2e-4: logging.info( "----> Wrong value detected (expected value: {})!". format(exp_value)) else: test_model(args=args)
from torchbench.image_classification import ImageNet from pytorch.pytorchcv.models.model_store import _model_sha1 from pytorch.pytorchcv.model_provider import get_model as ptcv_get_model import torchvision.transforms as transforms import torch import math from sys import version_info # import os for model_name, model_metainfo in (_model_sha1.items() if version_info[0] >= 3 else _model_sha1.iteritems()): net = ptcv_get_model(model_name, pretrained=True) error, checksum, repo_release_tag, caption, paper, ds, img_size, scale, batch, rem = model_metainfo if (ds != "in1k") or (img_size == 0) or ((len(rem) > 0) and (rem[-1] == "*")): continue paper_model_name = caption paper_arxiv_id = paper input_image_size = img_size resize_inv_factor = scale batch_size = batch model_description = "pytorch" + (rem if rem == "" else ", " + rem) assert (not hasattr(net, "in_size")) or (input_image_size == net.in_size[0]) ImageNet.benchmark( model=net, model_description=model_description, paper_model_name=paper_model_name, paper_arxiv_id=paper_arxiv_id, input_transform=transforms.Compose([ transforms.Resize(