Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Add SemanticSegmentationEvaluator #238

Merged
merged 21 commits into from
Jul 3, 2017

Conversation

yuyu2172
Copy link
Member

@yuyu2172 yuyu2172 commented Jun 1, 2017

merge after #217.

The current evaluate.py is wrong because n_positive adds up for pixels with "ignore" GT labels.
I made the following modification.

    for batch in it:
        img, gt_label = concat_examples(batch, args.gpu)
        img = chainer.Variable(img, volatile=True)
        pred_label = F.argmax(F.softmax(model(img)), axis=1)
        pred_label = cuda.to_cpu(pred_label.data)
        gt_label = cuda.to_cpu(gt_label)
        for cls_i in range(n_class):
            if cls_i in ignore_labels:
                continue
            pred_label = pred_label[gt_label != -1]
            gt_label = gt_label[gt_label != -1]
            n_positive[cls_i] += np.sum(pred_label == cls_i)
            n_true[cls_i] += np.sum(gt_label == cls_i)
            n_true_positive[cls_i] += np.sum(
                (pred_label == cls_i) * (gt_label == cls_i))

I set batchsize to one. This was critical to reproduce the results with SemanticSegmentationEvaluator.

                    Sky : 0.878988525
               Building : 0.668390287
                   Pole : 0.192338392
                   Road : 0.873874189
               Pavement : 0.642089768
                   Tree : 0.622743688
             SignSymbol : 0.189341867
                  Fence : 0.213735296
                    Car : 0.635499263
             Pedestrian : 0.273885917
              Bicyclist : 0.241545763
==================================
               mean IoU : 0.493857541
 Class average accuracy : 0.670468304
Global average accuracy : 0.826623129

With SemanticSegmentationEvaluator, the scores were as follows. This is identical to the score above.

                    Sky : 0.878988525
               Building : 0.668390287
                   Pole : 0.192338392
                   Road : 0.873874189
               Pavement : 0.642089768
                   Tree : 0.622743688
             SignSymbol : 0.189341867
                  Fence : 0.213735296
                    Car : 0.635499263
             Pedestrian : 0.273885917
              Bicyclist : 0.241545763
==================================
               mean IoU : 0.493857541
 Class average accuracy : 0.670468304
Global average accuracy : 0.826623129

@yuyu2172 yuyu2172 changed the title Add SemanticSegmentationEvaluator [WIP] Add SemanticSegmentationEvaluator Jun 1, 2017
@yuyu2172 yuyu2172 force-pushed the semantic-segmentation-evaluator branch 3 times, most recently from 9d808de to f8d0014 Compare June 1, 2017 15:19
@yuyu2172
Copy link
Member Author

yuyu2172 commented Jun 6, 2017

Since the content of this PR is not purely about SemanticSegmentationEvaluator, I split irrelevant part into #249.

@yuyu2172 yuyu2172 force-pushed the semantic-segmentation-evaluator branch from 9011c1e to 2ccc93f Compare June 6, 2017 08:22
@yuyu2172 yuyu2172 changed the title [WIP] Add SemanticSegmentationEvaluator Add SemanticSegmentationEvaluator Jun 14, 2017
@yuyu2172
Copy link
Member Author

I changed directory structure of extensions. This is the reason why I added no-compat label.

@yuyu2172
Copy link
Member Author

yuyu2172 commented Jul 3, 2017

@Hakuyume
Can you check this?

@Hakuyume
Copy link
Member

Hakuyume commented Jul 3, 2017

@yuyu2172 OK

following tuple :obj:`img, label`.
:obj:`img` is an image, :obj:`label` is pixel-wise label.
target (chainer.Link): A semantic segmentation link. This link should
have :meth:`predict` method which takes a list of images and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which -> that? #229 (comment)

returns :obj:`labels`.
label_names (iterable of strings): An iterable of names of classes.
If this value is specified, IoU and class accuracy for each class
is also reported with the keys
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is -> are

DetectionVisReport
~~~~~~~~~~~~~~~~~~
.. autofunction:: DetectionVisReport

DetectionVOCEvaluator
~~~~~~~~~~~~~~~~~~~~~
.. autofunction:: DetectionVOCEvaluator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a class (not a function)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've been using autofunction for many classes (e.g. Dataset class).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They should be fixed too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np.testing.assert_equal(eval_['target/pixel_accuracy'], 1.)
np.testing.assert_equal(eval_['target/mean_class_accuracy'], 1.)
np.testing.assert_equal(eval_['target/iou/a'], 1.)
np.testing.assert_equal(eval_['target/iou/b'], 1.)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make iou/a and iou/b different from each other?

@yuyu2172
Copy link
Member Author

yuyu2172 commented Jul 3, 2017

Thanks for reviewing.

Copy link
Member

@Hakuyume Hakuyume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Hakuyume Hakuyume merged commit dda1576 into chainer:master Jul 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants