chainer / chainercv

ChainerCV: a Library for Deep Learning in Computer Vision
MIT License
1.48k stars 304 forks source link

Color error when displaying bbox #861

Closed JosieHong closed 5 years ago

JosieHong commented 5 years ago

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]
knorth55 commented 5 years ago

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