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

Commit

Permalink
vis_label -> vis_semantic_segmentation
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyu2172 committed Sep 14, 2017
1 parent 716afcc commit 2fbdbbc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion chainercv/visualizations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from chainercv.visualizations.vis_bbox import vis_bbox # NOQA
from chainercv.visualizations.vis_image import vis_image # NOQA
from chainercv.visualizations.vis_keypoint import vis_keypoint # NOQA
from chainercv.visualizations.vis_label import vis_label # NOQA
from chainercv.visualizations.vis_semantic_segmentation import vis_semantic_segmentation # NOQA
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ def _default_cmap(label):
return r, g, b


def vis_label(
def vis_semantic_segmentation(
label, label_names=None,
label_colors=None, ignore_label_color=(0, 0, 0), alpha=1,
all_label_names_in_legend=False, ax=None):
"""Visualize a label for semantic segmentation.
"""Visualize a semantic segmentation.
Example:
Expand All @@ -32,12 +32,12 @@ def vis_label(
>>> from chainercv.datasets \
... import voc_semantic_segmentation_label_names
>>> from chainercv.visualizations import vis_image
>>> from chainercv.visualizations import vis_label
>>> from chainercv.visualizations import vis_semantic_segmentation
>>> import matplotlib.pyplot as plot
>>> dataset = VOCSemanticSegmentationDataset()
>>> img, label = dataset[60]
>>> ax = vis_image(img)
>>> _, legend_handles = vis_label(
>>> _, legend_handles = vis_semantic_segmentation(
... label,
... label_names=voc_semantic_segmentation_label_names,
... label_colors=voc_semantic_segmentation_label_colors,
Expand Down
6 changes: 3 additions & 3 deletions docs/source/reference/visualizations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ vis_keypoint
~~~~~~~~~~~~
.. autofunction:: vis_keypoint

vis_label
~~~~~~~~~
.. autofunction:: vis_label
vis_semantic_segmentation
~~~~~~~~~~~~~~~~~~~~~~~~~
.. autofunction:: vis_semantic_segmentation
5 changes: 3 additions & 2 deletions examples/segnet/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from chainercv.links import SegNetBasic
from chainercv import utils
from chainercv.visualizations import vis_image
from chainercv.visualizations import vis_label
from chainercv.visualizations import vis_semantic_segmentation


def main():
Expand Down Expand Up @@ -36,7 +36,8 @@ def main():
ax1 = fig.add_subplot(1, 2, 1)
vis_image(img, ax=ax1)
ax2 = fig.add_subplot(1, 2, 2)
vis_label(label, camvid_label_names, camvid_label_colors, ax=ax2)
vis_semantic_segmentation(
label, camvid_label_names, camvid_label_colors, ax=ax2)
plot.show()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from chainer import testing

from chainercv.visualizations import vis_label
from chainercv.visualizations import vis_semantic_segmentation

try:
import matplotlib # NOQA
Expand All @@ -17,15 +17,15 @@
'label_colors': [None, ((255, 0, 0), (0, 255, 0), (0, 0, 255))],
'all_label_names_in_legend': [False, True],
}))
class TestVisLabel(unittest.TestCase):
class TestVisSemanticSegmentation(unittest.TestCase):

def setUp(self):
self.label = np.random.randint(
-1, 3, size=(48, 64)).astype(np.int32)

def test_vis_label(self):
def test_vis_semantic_segmentation(self):
if optional_modules:
ax, legend_handles = vis_label(
ax, legend_handles = vis_semantic_segmentation(
self.label,
label_names=self.label_names, label_colors=self.label_colors,
all_label_names_in_legend=self.all_label_names_in_legend)
Expand All @@ -35,24 +35,24 @@ def test_vis_label(self):
self.assertIsInstance(handle, matplotlib.patches.Patch)


class TestVisLabelInvalidArguments(unittest.TestCase):
class TestVisSemanticSegmentationInvalidArguments(unittest.TestCase):

def test_vis_label_mismatch_names_and_colors(self):
def test_vis_semantic_segmentation_mismatch_names_and_colors(self):
label = np.random.randint(-1, 2, size=(48, 64)).astype(np.int32)

if optional_modules:
with self.assertRaises(ValueError):
vis_label(
vis_semantic_segmentation(
label,
label_names=('class0', 'class1', 'class2'),
label_colors=((255, 0, 0), (0, 255, 0)))

def test_vis_label_exceed_value(self):
def test_vis_semantic_segmentation_exceed_value(self):
label = np.random.randint(10, 20, size=(48, 64)).astype(np.int32)

if optional_modules:
with self.assertRaises(ValueError):
vis_label(
vis_semantic_segmentation(
label,
label_names=('class0', 'class1', 'class2'))

Expand Down

0 comments on commit 2fbdbbc

Please sign in to comment.