Exemplo n.º 1
0
    nl_edge=conf.nl_edge,
    nl_obj=conf.nl_obj,
    hidden_dim=conf.hidden_dim,
    use_proposals=conf.use_proposals,
    pass_in_obj_feats_to_decoder=conf.pass_in_obj_feats_to_decoder,
    pass_in_obj_feats_to_edge=conf.pass_in_obj_feats_to_edge,
    pooling_dim=conf.pooling_dim,
    rec_dropout=conf.rec_dropout,
    use_bias=conf.use_bias,
    use_tanh=conf.use_tanh,
    limit_vision=conf.limit_vision)

detector.cuda()
ckpt = torch.load(conf.ckpt)

optimistic_restore(detector, ckpt['state_dict'])
# if conf.mode == 'sgdet':
#     det_ckpt = torch.load('checkpoints/new_vgdet/vg-19.tar')['state_dict']
#     detector.detector.bbox_fc.weight.data.copy_(det_ckpt['bbox_fc.weight'])
#     detector.detector.bbox_fc.bias.data.copy_(det_ckpt['bbox_fc.bias'])
#     detector.detector.score_fc.weight.data.copy_(det_ckpt['score_fc.weight'])
#     detector.detector.score_fc.bias.data.copy_(det_ckpt['score_fc.bias'])

all_pred_entries = []


def val_batch(batch_num, b, evaluator, thrs=(20, 50, 100)):
    det_res = detector[b]
    if conf.num_gpus == 1:
        det_res = [det_res]
Exemplo n.º 2
0
fg_matrix, bg_matrix = get_counts(train_data=train, must_overlap=MUST_OVERLAP)

detector = ObjectDetector(classes=train.ind_to_classes, num_gpus=conf.num_gpus,
                          mode='rpntrain' if not conf.use_proposals else 'proposals', use_resnet=conf.use_resnet,
                          nms_filter_duplicates=True, thresh=0.01)
detector.eval()
detector.cuda()

classifier = ObjectDetector(classes=train.ind_to_classes, num_gpus=conf.num_gpus,
                            mode='gtbox', use_resnet=conf.use_resnet,
                            nms_filter_duplicates=True, thresh=0.01)
classifier.eval()
classifier.cuda()

ckpt = torch.load(conf.ckpt)
mismatch = optimistic_restore(detector, ckpt['state_dict'])
mismatch = optimistic_restore(classifier, ckpt['state_dict'])

MOST_COMMON_MODE = True

if MOST_COMMON_MODE:
    prob_matrix = fg_matrix.astype(np.float32)
    prob_matrix[:,:,0] = bg_matrix

    # TRYING SOMETHING NEW.
    prob_matrix[:,:,0] += 1
    prob_matrix /= np.sum(prob_matrix, 2)[:,:,None]
    # prob_matrix /= float(fg_matrix.max())

    np.save(os.path.join(DATA_PATH, 'pred_stats.npy'), prob_matrix)
    prob_matrix[:,:,0] = 0 # Zero out BG