Open JingyunLiang opened 5 years ago
Hi @JingyunLiang , This is because you directly send the string cat_name into the function, and it makes something like the following code:
if 'car' in 'carrot':
print(True)
Changing catId = coco.getCatIds(catNms=cat_name)
to catId = coco.getCatIds(catNms=[cat_name])
could avoid this problem.
When using
catId = coco.getCatIds(catNms=cat_name)
to get category id from category name, the function returns two category ids ([3,57]) for the namecarrot
, because it shares same characters withcar
.Just run the simple demo:
It prints
The same mistake happens to
bear & teddy bear
,dog & hot dog
.It's really tricky when conducting statistical analysis.