@@ -0,0 +1,1818 @@
+import argparse%0A%0Aimport chainer%0Afrom chainer import iterators%0A%0Afrom chainercv.datasets import VOCDetectionDataset%0Afrom chainercv.evaluations import voc_detection_eval%0Afrom chainercv.links import SSD300%0Afrom chainercv.links import SSD512%0A%0A%0Adef main():%0A    parser = argparse.ArgumentParser()%0A    parser.add_argument(%0A        '--model', choices=('ssd300', 'ssd512'), default='ssd300')%0A    parser.add_argument('--gpu', type=int, default=-1)%0A    parser.add_argument('--batchsize', type=int, default=32)%0A    args = parser.parse_args()%0A%0A    if args.model == 'ssd300':%0A        model = SSD300(pretrained_model='voc0712')%0A    elif args.model == 'ssd512':%0A        model = SSD512(pretrained_model='voc0712')%0A%0A    if args.gpu %3E= 0:%0A        chainer.cuda.get_device(args.gpu).use()%0A        model.to_gpu()%0A%0A    dataset = VOCDetectionDataset(%0A        year='2007', split='test', use_difficult=True, return_difficult=True)%0A    iterator = iterators.SerialIterator(%0A        dataset, args.batchsize, repeat=False, shuffle=False)%0A%0A    pred_bboxes = list()%0A    pred_labels = list()%0A    pred_scores = list()%0A    gt_bboxes = list()%0A    gt_labels = list()%0A    gt_difficults = list()%0A%0A    while True:%0A        try:%0A            batch = next(iterator)%0A        except StopIteration:%0A            break%0A%0A        imgs, bboxes, labels, difficults = zip(*batch)%0A        gt_bboxes.extend(bboxes)%0A        gt_labels.extend(labels)%0A        gt_difficults.extend(difficults)%0A%0A        bboxes, labels, scores = model.predict(imgs)%0A        pred_bboxes.extend(bboxes)%0A        pred_labels.extend(labels)%0A        pred_scores.extend(scores)%0A%0A    eval_ = voc_detection_eval(%0A        pred_bboxes, pred_labels, pred_scores,%0A        gt_bboxes, gt_labels, gt_difficults,%0A        use_07_metric=True)%0A%0A    print('mAP: ', eval_%5B'map'%5D)%0A%0A%0Aif __name__ == '__main__':%0A    main()%0A

add SSD eval