Python源码示例:models.model.load_model()
示例1
def __init__(self, options):
if options.gpus[0] >= 0:
try:
self.ctx = mx.gpu()
_ = nd.zeros((1,), ctx=self.ctx)
except mx.base.MXNetError:
print("No GPU available. Use CPU instead.")
self.ctx = mx.cpu()
else:
self.ctx = mx.cpu()
print("Creating model...")
self.model = create_model(options.arch, options.heads, options.head_conv, ctx = self.ctx)
if options.load_model_path != '':
self.model = load_model(self.model, options.load_model_path, ctx = self.ctx)
self.mean = np.array(options.mean, dtype=np.float32).reshape(1, 1, 3)
self.std = np.array(options.std, dtype=np.float32).reshape(1, 1, 3)
self.max_per_image = 100
self.num_classes = options.num_classes
self.scales = options.test_scales
self.opt = options
self.pause = True
示例2
def __init__(self, opt):
if opt.gpus[0] >= 0:
opt.device = torch.device('cuda')
else:
opt.device = torch.device('cpu')
print('Creating model...')
self.model = create_model(opt.arch, opt.heads, opt.head_conv)
self.model = load_model(self.model, opt.load_model)
self.model = self.model.to(opt.device)
self.model.eval()
self.mean = np.array(opt.mean, dtype=np.float32).reshape(1, 1, 3)
self.std = np.array(opt.std, dtype=np.float32).reshape(1, 1, 3)
self.max_per_image = 100
self.num_classes = opt.num_classes
self.scales = opt.test_scales
self.opt = opt
self.pause = True
示例3
def __init__(self, opt):
if opt.gpus[0] >= 0:
opt.device = torch.device('cuda')
else:
opt.device = torch.device('cpu')
print('Creating model...')
self.model = create_model(opt.arch, opt.heads, opt.head_conv)
self.model = load_model(self.model, opt.load_model)
self.model = self.model.to(opt.device)
self.model.eval()
self.mean = np.array(opt.mean, dtype=np.float32).reshape(1, 1, 3)
self.std = np.array(opt.std, dtype=np.float32).reshape(1, 1, 3)
self.max_per_image = 100
self.num_classes = opt.num_classes
self.scales = opt.test_scales
self.opt = opt
self.pause = True
示例4
def __init__(self, opt):
if opt.gpus[0] >= 0:
opt.device = torch.device('cuda')
else:
opt.device = torch.device('cpu')
print('Creating model...')
self.model = create_model(opt.arch, opt.heads, opt.head_conv)
self.model = load_model(self.model, opt.load_model)
self.model = self.model.to(opt.device)
self.model.eval()
self.mean = np.array(opt.mean, dtype=np.float32).reshape(1, 1, 3)
self.std = np.array(opt.std, dtype=np.float32).reshape(1, 1, 3)
self.max_per_image = 100
self.num_classes = opt.num_classes
self.scales = opt.test_scales
self.opt = opt
self.pause = True
示例5
def __init__(self, cfg):
print('Creating model...')
self.model = create_model(cfg.MODEL.NAME, cfg.MODEL.HEAD_CONV, cfg)
self.model = load_model(self.model, cfg.TEST.MODEL_PATH)
self.model = self.model.to(torch.device('cuda'))
self.model.eval()
self.mean = np.array(cfg.DATASET.MEAN, dtype=np.float32).reshape(1, 1, 3)
self.std = np.array(cfg.DATASET.STD, dtype=np.float32).reshape(1, 1, 3)
self.max_per_image = 100
self.num_classes = cfg.MODEL.NUM_CLASSES
self.scales = cfg.TEST.TEST_SCALES
self.cfg = cfg
self.pause = True