def test_anchor_target_layer(backend_default, fargs):
    (height, width) = fargs

    manifest_path = os.environ['PASCAL_MANIFEST_PATH']
    assert manifest_path is not None, "Please set the PASCAL_MANIFEST_PATH variable."

    manifest_root = os.environ['PASCAL_MANIFEST_ROOT']
    assert manifest_root is not None, "Please set the PASCAL_MANIFEST_ROOT variable."

    config = PASCALVOC(manifest_path, manifest_root, cache_dir='',
                       height=height, width=width, inference=False)
    config['subset_fraction'] = 0.1

    dl = DataLoader(config, backend_default)
    dl = TypeCast(dl, index=0, dtype=np.float32)
    train_set = ObjectLocalization(dl, frcn_rois_per_img=128)

    for idx, (X, Y) in enumerate(train_set):
        reference_test(train_set, X, Y)
Ejemplo n.º 2
0
assert args.model_file is not None, "Model file required for Faster-RCNN testing"
assert 'val' in args.manifest, "Path to manifest file requred"

# hyperparameters
assert args.batch_size is 1, "Faster-RCNN only supports batch size 1"
rpn_rois_per_img = 256
frcn_rois_per_img = 128

# setup backend
be = gen_backend(**extract_valid_args(args, gen_backend))

# build data loader
cache_dir = get_data_cache_dir(args.data_dir, subdir='pascalvoc_cache')
config = PASCALVOC(args.manifest['val'],
                   args.manifest_root,
                   width=args.width,
                   height=args.height,
                   rois_per_img=rpn_rois_per_img,
                   inference=True)

valid_set = faster_rcnn.build_dataloader(config, frcn_rois_per_img)

num_classes = valid_set.num_classes

# build the Faster-RCNN network
(model, proposalLayer) = faster_rcnn.build_model(valid_set,
                                                 frcn_rois_per_img,
                                                 inference=True)

# load parameters and initialize model
model.load_params(args.model_file, load_states=False)
model.initialize(dataset=valid_set)
Ejemplo n.º 3
0
rpn_rois_per_img = 256  # number of rois to sample to train rpn
frcn_rois_per_img = 128  # number of rois to sample to train frcn

# setup backend
be = gen_backend(**extract_valid_args(args, gen_backend))
be.enable_winograd = 4  # default to winograd 4 for fast autotune

# directory to store VGG weights
cache_dir = get_data_cache_dir(args.data_dir, subdir='pascalvoc_cache')

# build data loader
# get config file for PASCALVOC
config = PASCALVOC(args.manifest['train'],
                   args.manifest_root,
                   width=args.width,
                   height=args.height,
                   rois_per_img=rpn_rois_per_img,
                   inference=False)
config['subset_fraction'] = float(args.subset_pct / 100.0)

train_set = faster_rcnn.build_dataloader(config, frcn_rois_per_img)

# build the Faster-RCNN model
model = faster_rcnn.build_model(train_set, frcn_rois_per_img, inference=False)

# set up cost different branches, respectively
weights = 1.0 / (rpn_rois_per_img)
roi_w = 1.0 / (frcn_rois_per_img)

frcn_tree_cost = Multicost(costs=[
    GeneralizedCostMask(costfunc=CrossEntropyMulti(), weights=roi_w),