diff --git a/experiments/svm.yml b/experiments/svm.yml index 55d611fc807a4b56fb5c9ad693acf4361e761529..0966973d73d04ce38c7fe5ed23052f815a233539 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 02a42b96a551483406b83ca447bc716bc150846f..6bcb3efdb7ed5fe11d37d8a0087046a7e4363d28 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 d106e710d5abad99bba77971421e5bc45e08ea6c..3414acfc55caa51ab0b144ea16041b3c4afd97f3 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 2084b750ec28c40aafad6ecb3d0b94f8bb3656ff..cecbc31afd715facb05ba6bcfcf9dd86d0918fea 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()