Example #1
0
def main():
    args = parse_args()
    ctx = mx.gpu(args.gpu)
    symbol = get_resnet_test(num_classes=config.NUM_CLASSES,
                             num_anchors=config.NUM_ANCHORS)
    predictor = get_net(symbol, args.prefix, args.epoch, ctx)
    demo_net(predictor, args.image, args.vis)
Example #2
0
def main():
    args = parse_args()
    ctx = mx.gpu(args.gpu)
    sym = get_resnet_test(num_classes=config.NUM_CLASSES, num_anchors=config.NUM_ANCHORS)
    data, image_names, im_scales = load_data()
    predictor = get_net(data, sym, args.prefix, args.epoch, ctx)
    demo_net(predictor, data, image_names, im_scales)
Example #3
0
def create_net(configs):

    logger.info("[Python create_net] load configs: %s",
                configs,
                extra={"reqid": ""})
    tar_files_name = 'model_files'
    # load tar files
    if tar_files_name not in configs:
        return None, 400, {"code": 400, "message": 'no field "tar_files"'}

    tar_files = configs[tar_files_name]
    conf, err = net.parse_infer_config(tar_files)
    if err:
        return None, 400, {"code": 400, "message": err}

    params_file, sym_file, label_file = (conf.weight, conf.deploy_sym,
                                         conf.labels)

    use_device_name = 'use_device'
    if use_device_name not in configs:
        return None, 400, {"code": 400, "message": 'no field "use_device"'}
    use_device = configs[use_device_name]

    threshold = CONF_THRESH
    if 'custom_params' in configs:
        custom_values = configs['custom_params']
        if 'threshold' in custom_values:
            threshold = custom_values["threshold"]

    ctx = mx.gpu() if use_device == 'GPU' else mx.cpu()  # TODO set the gpu/cpu
    classes = _load_cls(label_file)
    symbol = get_resnet_test(num_classes=len(classes),
                             num_anchors=config.NUM_ANCHORS)

    os.rename(sym_file, sym_file + '-symbol.json')
    os.rename(params_file, sym_file + '-0000.params')

    logger.info("params_file: %s, sym_file:%s,label_file:%s",
                params_file,
                sym_file,
                label_file,
                extra={"reqid": ""})
    logger.info("use_device: %s, threshold:%s,classes:%s,symbol:%s",
                use_device,
                threshold,
                classes,
                symbol,
                extra={"reqid": ""})

    return dict(error='',
                predictor=get_net(symbol, sym_file, 0, ctx),
                classes=classes,
                threshold=threshold), 0, None
Example #4
0
                        help='saved model prefix',
                        default='model/e2e',
                        type=str)
    parser.add_argument('--epoch',
                        help='epoch of pretrained model',
                        default=50,
                        type=int)
    parser.add_argument('--gpu', help='GPU device to use', default=0, type=int)
    parser.add_argument('--vis', help='display result', action='store_true')
    args = parser.parse_args()
    return args


if __name__ == '__main__':
    args = parse_args()
    ctx = mx.gpu(0)
    if (Global.prefix_value == 'model/e2e'):
        symbol = get_resnet_test(num_classes=Global.num_class_value,
                                 num_anchors=config.NUM_ANCHORS)
    if (Global.prefix_value == 'model/final'):
        symbol = get_vgg_test(num_classes=Global.num_class_value,
                              num_anchors=config.NUM_ANCHORS)
    predictor = get_net(symbol, args.prefix, ctx)
    from glob import glob
    res = glob("/root/mx-rcnn/testimage/bird/*.JPG")
    cnt = 0
    for i in res:
        demo_net(predictor, i, False)
        # if cnt>10:
# break