From 44c04129c0ac0debd0d44b13d8d30518592209b4 Mon Sep 17 00:00:00 2001 From: Ross Girshick <ross.girshick@gmail.com> Date: Tue, 21 Apr 2015 10:25:52 -0700 Subject: [PATCH] TEST: BINARY -> SVM --- experiments/svm.yml | 7 ++++++- src/fast_rcnn_config.py | 6 +++--- src/fast_rcnn_test.py | 7 +++---- tools/extra/train_svms.py | 6 ++++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/experiments/svm.yml b/experiments/svm.yml index 55d611f..0966973 100644 --- a/experiments/svm.yml +++ b/experiments/svm.yml @@ -1,3 +1,8 @@ EXP_DIR: svm +TRAIN: + # don't use flipped examples when training SVMs for two reasons: + # 1) R-CNN didn't + # 2) I've tried and it doesn't help, yet makes SVM training take 2x longer + USE_FLIPPED: False TEST: - BINARY: True + SVM: True diff --git a/src/fast_rcnn_config.py b/src/fast_rcnn_config.py index 02a42b9..6bcb3ef 100644 --- a/src/fast_rcnn_config.py +++ b/src/fast_rcnn_config.py @@ -97,9 +97,9 @@ __C.TEST.MAX_SIZE = 1000 # IoU >= this threshold) __C.TEST.NMS = 0.3 -# Experimental: use binary logistic regression scores instead of K-way softmax -# scores when testing -__C.TEST.BINARY = False +# Experimental: treat the (K+1) units in the cls_score layer as linear +# predictors (trained, eg, with one-vs-rest SVMs). +__C.TEST.SVM = False # Test using bounding-box regressors __C.TEST.BBOX_REG = True diff --git a/src/fast_rcnn_test.py b/src/fast_rcnn_test.py index d106e71..3414acf 100644 --- a/src/fast_rcnn_test.py +++ b/src/fast_rcnn_test.py @@ -136,11 +136,10 @@ def im_detect(net, im, boxes): net.blobs['rois'].reshape(*(blobs['rois'].shape)) blobs_out = net.forward(data=blobs['data'].astype(np.float32, copy=False), rois=blobs['rois'].astype(np.float32, copy=False)) - if cfg.TEST.BINARY: - # simulate binary logistic regression + if cfg.TEST.SVM: + # use the raw scores before softmax under the assumption they + # were trained as linear SVMs scores = net.blobs['cls_score'].data - # Return scores as fg - bg - scores = scores - scores[:, 0][:, np.newaxis] else: # use softmax estimated probabilities scores = blobs_out['cls_prob'] diff --git a/tools/extra/train_svms.py b/tools/extra/train_svms.py index 2084b75..cecbc31 100755 --- a/tools/extra/train_svms.py +++ b/tools/extra/train_svms.py @@ -265,10 +265,12 @@ def parse_args(): if __name__ == '__main__': # Must turn this off to prevent issues when digging into the net blobs to - # pull out features + # pull out features (tricky!) cfg.DEDUP_BOXES = 0 - cfg.TEST.BINARY = True + # Must turn this on because we use the test im_detect() method to harvest + # hard negatives + cfg.TEST.SVM = True args = parse_args() -- GitLab