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

Show in legend only classes that appear in an image for vis_label #345

Merged
merged 6 commits into from
Jul 21, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chainercv/visualizations/vis_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def vis_label(
ax.imshow(img)

legend_handles = list()
for l, label_name in enumerate(label_names):
for l in np.unique(label):
Copy link
Member

Choose a reason for hiding this comment

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

We should skip ignored label.

if l < 0:
    continue

legend_handles.append(
Patch(color=cmap(l / (n_class - 1)), label=label_name))
Patch(color=cmap(l / (n_class - 1)), label=label_names[l]))

return ax, legend_handles