コード例 #1
0
def setup_paper_model(model_chkpt_path, sess):
    net = resnet_fusion(batch_size=1, num_layers=101) # Using code from lib/model/test.py

    # Load Model (instead of .json)
    net.create_architecture(sess, "TEST", 2, tag='default',
                            anchor_scales=cfg.ANCHOR_SCALES,
                            anchor_ratios=[8, 16, 32, 64])

    saver = tf.train.Saver()
    saver.restore(sess, model_chkpt_path) # Load weights
    return net
コード例 #2
0
ファイル: data_creation.py プロジェクト: garnav/RGB-N
def test_net_creation(file_name, model_chkpt_path):
    #imdb = get_imdb(imdb_name)
    tfconfig = tf.ConfigProto(allow_soft_placement=True)
    tfconfig.gpu_options.allow_growth=True

    with tf.Session(config=tfconfig) as sess:
        net = resnet_fusion(batch_size=1, num_layers=101)

        # Load Model (instead of .json)
        net.create_architecture(sess, "TEST", 2, tag='default',
                                anchor_scales=cfg.ANCHOR_SCALES,
                                anchor_ratios=[8, 16, 32, 64])

        saver = tf.train.Saver()
        saver.restore(sess, model_chkpt_path) # Load weights
        run_image(sess, net, file_name)
コード例 #3
0
ファイル: data_creation.py プロジェクト: garnav/RGB-N
def create_dataset(image_dir, model_chkpt_path, img_processed_truth_paths):
    tfconfig = tf.ConfigProto(allow_soft_placement=True)
    tfconfig.gpu_options.allow_growth=True

    with tf.Session(config=tfconfig) as sess:
        net = resnet_fusion(batch_size=1, num_layers=101) # Using code from lib/model/test.py

        # Load Model (instead of .json)
        net.create_architecture(sess, "TEST", 2, tag='default',
                                anchor_scales=cfg.ANCHOR_SCALES,
                                anchor_ratios=[8, 16, 32, 64])

        saver = tf.train.Saver()
        saver.restore(sess, model_chkpt_path) # Load weights

        all_image_files = os.listdir(image_dir)

        with open(img_processed_truth_paths, 'r') as fi_file:
            im_processed_truth = json.load(fi_file)

        img_rois = []
        for i, image_path in enumerate(all_image_files):
            try:
                print(i)
                if image_path in im_processed_truth:
                    roi_features, rois = run_image(sess, net, os.path.join(image_dir, image_path))
                    reduecd_roi_indices = reduce_data(rois, im_processed_truth[image_path])

                    if reduecd_roi_indices not None:
                        for roi_i, idx in enumerate(list(map(int, reduecd_roi_indices['gt'] + reduecd_roi_indices['other']))):
                            # save data
                            filename = "roi_feature_map_{0}_{1}".format(i, roi_i)
                            #print(os.path.join(X_DATA_DIR, filename))
                            np.save(os.path.join(X_DATA_DIR, filename), roi_features[idx, :, :, :])

                        # save rois
                        img_rois.append(rois)
                
            except Exception as e:
                print(e)
            
            #periodically save img_rois
            if i % 500 == 0:
                np.save(os.path.join(Y_DATA_DIR, LABELS_PATH), img_rois)
コード例 #4
0
     net = vgg16(batch_size=cfg.TRAIN.IMS_PER_BATCH)
 elif args.net == 'vgg16_noise':
     net = vgg16_noise(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 == 'res50_noise':
     net = resnet_noise(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 == 'res101_noise':
     net = resnet_noise(batch_size=cfg.TRAIN.IMS_PER_BATCH, num_layers=101)
 elif args.net == 'res101_noise_init':
     net = resnet_noise_init(batch_size=cfg.TRAIN.IMS_PER_BATCH,
                             num_layers=101)
 elif args.net == 'res101_fusion':
     net = resnet_fusion(batch_size=cfg.TRAIN.IMS_PER_BATCH, num_layers=101)
 elif args.net == 'res101_fusion_2rpn':
     net = resnet_fusion_2rpn(batch_size=cfg.TRAIN.IMS_PER_BATCH,
                              num_layers=101)
 elif args.net == 'res101_fusion_2rpn_sep':
     net = resnet_fusion_2rpn_sep(batch_size=cfg.TRAIN.IMS_PER_BATCH,
                                  num_layers=101)
 elif args.net == 'res101_fusion_late_fusion':
     net = resnet_fusion_late_fusion(batch_size=cfg.TRAIN.IMS_PER_BATCH,
                                     num_layers=101)
 elif args.net == 'res101_fusion_noise':
     net = resnet_fusion_noise(batch_size=cfg.TRAIN.IMS_PER_BATCH,
                               num_layers=101)
 elif args.net == 'res101_fusion_fix':
     net = resnet_fusion_fix(batch_size=cfg.TRAIN.IMS_PER_BATCH,
                             num_layers=101)
コード例 #5
0
ファイル: test_net.py プロジェクト: zhangqizky/RGB-N
    # init session
    sess = tf.Session(config=tfconfig)
    # load network
    if args.net == 'vgg16':
        net = vgg16(batch_size=1)
    elif args.net == 'res50':
        net = resnetv1(batch_size=1, num_layers=50)
    elif args.net == 'res101':
        net = resnetv1(batch_size=1, num_layers=101)
    elif args.net == 'res101_noise':
        net = resnet_noise(batch_size=1, num_layers=101)
    elif args.net == 'res101_noise_init':
        net = resnet_noise_init(batch_size=1, num_layers=101)
    elif args.net == 'res101_fusion':
        net = resnet_fusion(batch_size=1, num_layers=101)
    elif args.net == 'res101_fusion_noise':
        net = resnet_fusion_noise(batch_size=1, num_layers=101)
    elif args.net == 'res152':
        net = resnetv1(batch_size=1, num_layers=152)
    else:
        raise NotImplementedError

    # load model
    net.create_architecture(sess,
                            "TEST",
                            imdb.num_classes,
                            tag='default',
                            anchor_scales=cfg.ANCHOR_SCALES,
                            anchor_ratios=cfg.ANCHOR_RATIOS)