コード例 #1
0
ファイル: train_voc.py プロジェクト: bhfs9999/FasterRCNN_GPU
        net = FPN(
            FPN_Resnet(resnet_type=101,
                       feat_strdie=(4, 8, 16, 32, 64),
                       anchor_scales=cfg.ANCHOR_SCALES,
                       anchor_ratios=cfg.ANCHOR_RATIOS), imdb.classes)
        cfg.TRAIN.INIT_WAY = 'resnet'
    else:
        raise NotImplementedError

    learn_dict = {
        'disp_interval': cfg.TRAIN.DISPLAY,
        'use_tensorboard': cfg.TRAIN.USE_TENSORBOARD,
        'use_valid': cfg.TRAIN.USE_VALID,
        'evaluate': cfg.TRAIN.EVALUATE,
        'begin_eval_point': cfg.TRAIN.BEGIN_EVAL_POINT,
        'save_point_interval': cfg.TRAIN.SAVE_POINT_INTERVAL,
        'lr_decay_steps': cfg.TRAIN.STEPSIZE
    }
    resume = args.resume

    train_net(net,
              imdb,
              valimdb,
              roidb,
              valroidb,
              model_dir,
              learn_dict,
              resume,
              pretrained_model=args.weight,
              max_iters=args.max_iters)
コード例 #2
0
    tb_dir = get_output_tb_dir(imdb, args.tag)
    print('TensorFlow summaries will be saved to `{:s}`'.format(tb_dir))

    # also add the validation set, but with no flipping images
    orgflip = cfg.TRAIN.USE_FLIPPED
    cfg.TRAIN.USE_FLIPPED = False
    _, valroidb = combined_roidb(args.imdbval_name)
    print('{:d} validation roidb entries'.format(len(valroidb)))
    cfg.TRAIN.USE_FLIPPED = orgflip

    # load network
    if args.net == 'vgg16':
        net = vgg16(batch_size=cfg.TRAIN.IMS_PER_BATCH)
    elif args.net == 'res50':
        net = resnetv1(batch_size=cfg.TRAIN.IMS_PER_BATCH, num_layers=50)
    elif args.net == 'res101':
        net = resnetv1(batch_size=cfg.TRAIN.IMS_PER_BATCH, num_layers=101)
    elif args.net == 'res152':
        net = resnetv1(batch_size=cfg.TRAIN.IMS_PER_BATCH, num_layers=152)
    else:
        raise NotImplementedError

    train_net(net,
              imdb,
              roidb,
              valroidb,
              output_dir,
              tb_dir,
              pretrained_model=args.weight,
              max_iters=args.max_iters)
コード例 #3
0
  print(im)
  '''

    weights_filename = 'default'
    output_dir = get_output_dir(imdb, weights_filename)
    print('Output will be saved to `{:s}`'.format(output_dir))
    # tb_dir = get_output_tb_dir(imdb,weights_filename)

    net = vgg16()
    orgflip = cfg.TRAIN.USE_FLIPPED
    cfg.TRAIN.USE_FLIPPED = False
    valimdb, valroidb = get_roidb('voc_2007_test')  #获取测试集数据
    #测试验证集数据
    #im=cv2.imread(valroidb[6000]['image']
    #print(im)

    print('{:d} validatio  n roidb entries'.format(len(valroidb)))
    cfg.TRAIN.USE_FLIPPED = orgflip
    #截止目前测试均通过

    #在源码基础上去除了很多冗余的东西。。但开始报错了
    train_net(net,
              imdb,
              roidb,
              valroidb,
              output_dir,
              pretrained_model=pretrained_model,
              max_iters=40000)

    # load network