chainer / chainercv

ChainerCV: a Library for Deep Learning in Computer Vision

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Color error when displaying bbox

JosieHong opened this issue · comments

I tried to use the visualizations.vis_bbox(), but the colors and the labels did not correspond.

colors = voc_colormap(label + 1)
vis_bbox(img, bbox, label, 
              label_names=voc_bbox_label_names, 
              instance_colors=colors)
plt.show()

Then I found that in chainercv/visualizations/vis_bbox.py the instance_colors didn't be sorted by score. I rewrote the sorted part like folowing and the color works right.

if sort_by_score and score is not None:
    order = np.argsort(score)
    bbox = bbox[order]
    score = score[order]
    # Sorted the instance_colors
    instance_colors = instance_colors[order]
    if label is not None:
        label = label[order]

Thank you for the report. I made a PR to fix this issue. #908