当前位置: 首页>>代码示例>>Python>>正文


Python model.create_model方法代码示例

本文整理汇总了Python中models.model.create_model方法的典型用法代码示例。如果您正苦于以下问题:Python model.create_model方法的具体用法?Python model.create_model怎么用?Python model.create_model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.model的用法示例。


在下文中一共展示了model.create_model方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from models import model [as 别名]
# 或者: from models.model import create_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 
开发者ID:Guanghan,项目名称:mxnet-centernet,代码行数:25,代码来源:base_detector.py

示例2: __init__

# 需要导入模块: from models import model [as 别名]
# 或者: from models.model import create_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 
开发者ID:CaoWGG,项目名称:CenterNet-CondInst,代码行数:21,代码来源:base_detector.py

示例3: main

# 需要导入模块: from models import model [as 别名]
# 或者: from models.model import create_model [as 别名]
def main(cfg):

    model = create_model('res_50', cfg.MODEL.HEAD_CONV, cfg).cuda()

    weight_path = '/home/tensorboy/data/centerpose/trained_best_model/res_50_best_model.pth'
    state_dict = torch.load(weight_path, map_location=lambda storage, loc: storage)['state_dict']
    model.load_state_dict(state_dict)

    onnx_file_path = "./model/resnet50.onnx"
    
    #img = cv2.imread('test_image.jpg')
    image = cv2.imread('../images/image1.jpg')
    images, meta = pre_process(image, cfg, scale=1)

    model.cuda()
    model.eval()
    model.float()
    torch_input = images.cuda()
    print(torch_input.shape)
        
    torch.onnx.export(model, torch_input, onnx_file_path, verbose=False)
    sess = nxrun.InferenceSession(onnx_file_path)
    
    input_name = sess.get_inputs()[0].name
    label_name = sess.get_outputs()[0].name
    
    print(input_name)
    print(sess.get_outputs()[0].name)
    print(sess.get_outputs()[1].name)
    print(sess.get_outputs()[2].name)
    output_onnx = sess.run(None, {input_name:  images.cpu().data.numpy()})
    hm, wh, hps, reg, hm_hp, hp_offset = output_onnx  
    print(hm)
    print(len(output_onnx)) 
开发者ID:tensorboy,项目名称:centerpose,代码行数:36,代码来源:convert2onnx.py

示例4: __init__

# 需要导入模块: from models import model [as 别名]
# 或者: from models.model import create_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 
开发者ID:tensorboy,项目名称:centerpose,代码行数:17,代码来源:base_detector.py


注:本文中的models.model.create_model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。