Пример #1
0
# hyperparameters
args.batch_size = 1
n_mb = 40
img_per_batch = args.batch_size
rois_per_img = 5403

# setup dataset
image_set = 'test'
image_year = '2007'
valid_set = PASCALVOCInference(image_set, image_year, path=args.data_dir, n_mb=n_mb,
                               rois_per_img=rois_per_img, shuffle=False)

# setup model

model = create_frcn_model()
model.load_params(args.model_file)
model.initialize(dataset=valid_set)

CONF_THRESH = 0.8
NMS_THRESH = 0.3

# iterate through minibatches of the dataset
for mb_idx, (x, db) in enumerate(valid_set):

    im = np.array(Image.open(db['img_file']))  # This is RGB order
    neon_logger.display(db['img_id'])

    outputs = model.fprop(x, inference=True)

    scores, boxes = valid_set.post_processing(outputs, db)
Пример #2
0
    be.enable_winograd = 4
    if be.gpu_memory_size < 11 * 1024 * 1024 * 1024:
        exit("ERROR: This model requires at least 11GB GPU memory to be run.")

# setup training dataset
train_set = PASCALVOCTrain('trainval', '2007', path=args.data_dir, n_mb=n_mb,
                           img_per_batch=img_per_batch, rois_per_img=rois_per_img,
                           rois_random_sample=True,
                           add_flipped=False, subset_pct=args.subset_pct)
test_set = PASCALVOCTrain('test', '2007', path=args.data_dir, n_mb=n_mb,
                          img_per_batch=img_per_batch, rois_per_img=rois_per_img,
                          rois_random_sample=True,
                          add_flipped=False)

# setup model
model = create_frcn_model(frcn_fine_tune)

# setup optimizer
opt_w = GradientDescentMomentum(
    0.001 * learning_rate_scale, 0.9, wdecay=0.0005)
opt_b = GradientDescentMomentum(0.002 * learning_rate_scale, 0.9)

optimizer = MultiOptimizer({'default': opt_w, 'Bias': opt_b})

# if training a new model, seed the image model conv layers with pre-trained weights
# otherwise, just load the model file
if args.model_file is None:
    load_vgg_weights(model, args.data_dir)

cost = Multicost(costs=[GeneralizedCostMask(costfunc=CrossEntropyMulti()),
                        GeneralizedCostMask(costfunc=SmoothL1Loss())],