You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My team and I are running a training on custom dataset.
We realized there is a discrepency in detectron2 code and documentation on whether the category_ids should be in the range [0, num_categories-1] or [1, num_categories]
The documentation states that the category_ids should be in the range [0, num_categories-1]
Lines 82-98 in detectron2/data/datasets/coco.py
The description says that category_ids are expected to be in [0,80) but the code throws a warning if it's not in [1, 80]. Funny enough it re-maps it to [0, 80) after that warning.
# In COCO, certain category ids are artificially removed,
# and by convention they are always ignored.
# We deal with COCO's id issue and translate
# the category ids to contiguous ids in [0, 80).
# It works by looking at the "categories" field in the json, therefore
# if users' own json also have incontiguous ids, we'll
# apply this mapping as well but print a warning.
if not (min(cat_ids) == 1 and max(cat_ids) == len(cat_ids)):
if "coco" not in dataset_name:
logger.warning(
"""
Category ids in annotations are not in [1, #categories]! We'll apply a mapping for you.
"""
)
id_map = {v: i for i, v in enumerate(cat_ids)}
meta.thing_dataset_id_to_contiguous_id = id_map
I think for consistency, the code checking for min and max should be changed to if not (min(cat_ids) == 0 and max(cat_ids) == len(cat_ids)-1)
Slightly unrelated concern is that in coco_evaluation, the num_classes are being read from the dataset and not the config which can be an issue if the dataset doesn't have all classes in it. Lines 230-235 in evaluation/coco_evaluation.py
# unmap the category ids for COCO
if hasattr(self._metadata, "thing_dataset_id_to_contiguous_id"):
dataset_id_to_contiguous_id = self._metadata.thing_dataset_id_to_contiguous_id
all_contiguous_ids = list(dataset_id_to_contiguous_id.values())
num_classes = len(all_contiguous_ids)
assert min(all_contiguous_ids) == 0 and max(all_contiguous_ids) == num_classes - 1
You've chosen to report an unexpected problem or bug. Unless you already know the root cause of it, please include details about it by filling the issue template.
The following information is missing: "Instructions To Reproduce the Issue and Full Logs"; "Your Environment";
My team and I are running a training on custom dataset.
We realized there is a discrepency in detectron2 code and documentation on whether the category_ids should be in the range [0, num_categories-1] or [1, num_categories]
The documentation states that the category_ids should be in the range [0, num_categories-1]
Lines 82-98 in detectron2/data/datasets/coco.py
The description says that category_ids are expected to be in [0,80) but the code throws a warning if it's not in [1, 80]. Funny enough it re-maps it to [0, 80) after that warning.
I think for consistency, the code checking for min and max should be changed to
if not (min(cat_ids) == 0 and max(cat_ids) == len(cat_ids)-1)
Slightly unrelated concern is that in coco_evaluation, the num_classes are being read from the dataset and not the config which can be an issue if the dataset doesn't have all classes in it.
Lines 230-235 in evaluation/coco_evaluation.py
Environment:
Instructions To Reproduce the Issue:
The text was updated successfully, but these errors were encountered: