Commit a32acb81 authored by Ross Girshick's avatar Ross Girshick

re-eval: option to use mat files; some pylint fixes

parent 1e85e7d9
......@@ -120,7 +120,7 @@ __C.RNG_SEED = 3
__C.EPS = 1e-14
# Root directory of project
__C.ROOT_DIR = ops.abspath(osp.join(osp.dirname(__file__), '..', '..'))
__C.ROOT_DIR = osp.abspath(osp.join(osp.dirname(__file__), '..', '..'))
# Place outputs under an experiments directory
__C.EXP_DIR = 'default'
......
......@@ -14,11 +14,10 @@ import caffe
import utils.cython_nms
import cPickle
import heapq
import utils.blob
from utils.blob import im_list_to_blob
import os
def _get_image_blob(im):
im_pyra = []
im_orig = im.astype(np.float32, copy=True)
im_orig -= cfg.PIXEL_MEANS
......@@ -40,7 +39,7 @@ def _get_image_blob(im):
processed_ims.append(im)
# Create a blob to hold the input images
blob = utils.blob.im_list_to_blob(processed_ims)
blob = im_list_to_blob(processed_ims)
return blob, np.array(im_scale_factors)
......@@ -117,7 +116,7 @@ def _clip_boxes(boxes, im_shape):
return boxes
def im_detect(net, im, boxes):
blobs, im_scale_factors = _get_blobs(im, boxes)
blobs, unused_im_scale_factors = _get_blobs(im, boxes)
# When mapping from image ROIs to feature map ROIs, there's some aliasing
# (some distinct image ROIs get mapped to the same feature ROI).
......
......@@ -7,10 +7,9 @@
from fast_rcnn.config import cfg, get_output_path
import numpy as np
import cv2
import caffe
import finetuning
import bbox_regression_targets
import fast_rcnn.finetuning as finetuning
import fast_rcnn.bbox_regression_targets as bbox_regression_targets
import os
from caffe.proto import caffe_pb2
......@@ -77,7 +76,7 @@ class SolverWrapper(object):
for shuffled_i in xrange(0, len(shuffled_inds),
cfg.TRAIN.IMS_PER_BATCH):
db_inds = shuffled_inds[shuffled_i:shuffled_i +
cfg.TRAIN.IMS_PER_BATCH]
cfg.TRAIN.IMS_PER_BATCH]
minibatch_db = [roidb[i] for i in db_inds]
blobs = finetuning.get_minibatch(minibatch_db)
......
......@@ -6,8 +6,29 @@ from fast_rcnn.config import cfg
from datasets.factory import get_imdb
import cPickle
import os, sys
import numpy as np
def main(imdb_name, output_dir):
def from_mats(imdb_name, output_dir):
import scipy.io as sio
imdb = get_imdb(imdb_name)
aps = []
for i, cls in enumerate(imdb.classes[1:]):
mat = sio.loadmat(os.path.join(output_dir, cls + '_pr.mat'))
ap = mat['ap'][0, 0] * 100
apAuC = mat['ap_auc'][0, 0] * 100
print '!!! {} : {:.1f} {:.1f}'.format(cls, ap, apAuC)
aps.append(ap)
print '~~~~~~~~~~~~~~~~~~~'
print 'Results (from mat files):'
for ap in aps:
print '{:.1f}'.format(ap)
print '{:.1f}'.format(np.array(aps).mean())
print '~~~~~~~~~~~~~~~~~~~'
def from_dets(imdb_name, output_dir):
imdb = get_imdb(imdb_name)
imdb.config['use_salt'] = False
imdb.config['cleanup'] = False
......@@ -26,4 +47,8 @@ if __name__ == '__main__':
output_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),
'..', output_dir))
imdb_name = 'voc_2007_test'
main(imdb_name, output_dir)
if len(sys.argv) > 2:
from_mats(imdb_name, output_dir)
else:
from_dets(imdb_name, output_dir)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment