correspondence between .png annotation & category_id
iTomxy opened this issue · 2 comments
iTomxy commented
It's said in Caffe-compatible stuff-thing maps that thing+stuff labels cover indices 0-181 and 255 indicates the 'unlabeled' or void class.
However, the mapping in labels.txt seems not match.
iTomxy commented
a simple demo:
import os
import sys
import numpy as np
import cv2
import matplotlib.pyplot as plt
P = "G:/dataset/COCO-stuff"
ANNO_P = os.path.join(P, "annotations/val2017")
LABEL_F = os.path.join(P, "cocostuff", "labels.txt")
id_cls = {}
with open(LABEL_F, "r") as f:
for line in f:
cid, cname = line.strip().split(": ")
id_cls[int(cid)] = cname
# print(cid, ":", cname)
mask_f = os.path.join(ANNO_P, "000000397133.png")
mask = cv2.imread(mask_f)
print(mask.min(), mask.max())
for c in range(mask.max()):
m = (mask == c)
area = m.sum()
if area > 0:
print(c, id_cls[c]) # `0` should be `person`, but output `unlabeled` !
plt.imshow(np.where(m, c, 255))
plt.show()
break
nightrome commented
Yes, that is correct:
- Default dataset: 1-182 are valid classes.
- Caffe: 0-181 are valid classes.
- Separate stuff and thing downloads: Same as Default for stuff classes,, but
the stuff annotations contain a class 'other' with index 183 that covers all non-stuff pixels.
.