本文整理汇总了Python中models.model.load_model方法的典型用法代码示例。如果您正苦于以下问题:Python model.load_model方法的具体用法?Python model.load_model怎么用?Python model.load_model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.model
的用法示例。
在下文中一共展示了model.load_model方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from models import model [as 别名]
# 或者: from models.model import load_model [as 别名]
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: __init__
# 需要导入模块: from models import model [as 别名]
# 或者: from models.model import load_model [as 别名]
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: __init__
# 需要导入模块: from models import model [as 别名]
# 或者: from models.model import load_model [as 别名]
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