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

Add vis instance segmentation func #541

Merged
merged 3 commits into from
Mar 26, 2018

Conversation

knorth55
Copy link
Contributor

@knorth55 knorth55 commented Mar 21, 2018

Merge after #540

  • add vis_instance_segmentation
  • add test_vis_instance_segmentation_dataset.py
from chainercv.datasets import SBDInstanceSegmentationDataset
from chainercv.datasets import sbd_instance_segmentation_label_names
from chainercv.visualizations import vis_instance_segmentation
import matplotlib.pyplot as plt

dataset = SBDInstanceSegmentationDataset()
img, bbox, mask, label = dataset[0]
vis_instance_segmentation(
    img, bbox, mask, label, label_names=sbd_instance_segmentation_label_names,
    alpha=0.7)
plt.show()

ins_dataset_example

@knorth55 knorth55 force-pushed the add-vis-instance-segmentation branch from 8019556 to 59604e2 Compare March 21, 2018 04:08
@knorth55 knorth55 requested a review from yuyu2172 March 21, 2018 04:08
@knorth55 knorth55 self-assigned this Mar 21, 2018
@knorth55 knorth55 force-pushed the add-vis-instance-segmentation branch from 59604e2 to 7b14cfa Compare March 21, 2018 04:26
@yuyu2172 yuyu2172 mentioned this pull request Mar 21, 2018
21 tasks
@knorth55 knorth55 force-pushed the add-vis-instance-segmentation branch 4 times, most recently from 2003d55 to 10d8d69 Compare March 22, 2018 00:41
if score is not None and not len(bbox) == len(score):
raise ValueError('The length of score must be same as that of bbox')

n_ins_class = len(bbox)
Copy link
Member

Choose a reason for hiding this comment

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

s/n_ins_class/n_inst

n_ins_class sounds like this is related to class categories.

raise ValueError('The length of score must be same as that of bbox')

n_ins_class = len(bbox)
colors = [_default_cmap(l) for l in range(n_ins_class + 1)]
Copy link
Member

Choose a reason for hiding this comment

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

How about range(1, n_inst)?
By doing so, you can remove one line.
Also, np.array is optional in this case, so we can omit it.

if label is not None and not len(bbox) == len(label):
raise ValueError('The length of label must be same as that of bbox')
if score is not None and not len(bbox) == len(score):
raise ValueError('The length of score must be same as that of bbox')
Copy link
Member

Choose a reason for hiding this comment

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

How about checking mask as well?

# Returns newly instantiated matplotlib.axes.Axes object if ax is None
ax = vis_image(img, ax=ax)

vis_img = np.zeros((mask.shape[1], mask.shape[2], 4), dtype=np.uint8)
Copy link
Member

Choose a reason for hiding this comment

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

vis_img has very similar name to vis_image.
How about canvas?

This is in RGB format and the range of its value is
:math:`[0, 255]`.
bbox (~numpy.ndarray): A float array of shape :math:`(R, 4)`.
R is the number of objects in the image, and each vector
Copy link
Member

Choose a reason for hiding this comment

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

R --> `:math:`R``

>>> from chainercv.datasets import SBDInstanceSegmentationDataset
>>> from chainercv.datasets \
... import sbd_instance_segmentation_label_names
>>> from chainercv.visualizations import vis_image
Copy link
Member

Choose a reason for hiding this comment

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

We do not need vis_image

@knorth55 knorth55 force-pushed the add-vis-instance-segmentation branch from 10d8d69 to 0b934de Compare March 26, 2018 04:49
@yuyu2172
Copy link
Member

Please rebase master

@knorth55 knorth55 force-pushed the add-vis-instance-segmentation branch 2 times, most recently from 705e2fd to f53bc22 Compare March 26, 2018 05:23
@knorth55
Copy link
Contributor Author

i rebased and updated

:obj:`label_names`.
label_names (iterable of strings): Name of labels ordered according
to label ids.
alpha (float): The value which determines transparency of the figure.
Copy link
Member

Choose a reason for hiding this comment

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

Is alpha=1 a reasonable default value?
To me, alpha=0.7 looks better.
Also, the doc needs to be changed if we are changing this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer alpha=0.7, so I will change it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated.

@knorth55 knorth55 force-pushed the add-vis-instance-segmentation branch from f53bc22 to d163005 Compare March 26, 2018 09:15
@yuyu2172 yuyu2172 merged commit b8280c2 into chainer:master Mar 26, 2018
@knorth55 knorth55 deleted the add-vis-instance-segmentation branch March 26, 2018 12:29
@yuyu2172 yuyu2172 added this to the v0.9 milestone Apr 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants