#1857·YOLOX

COCOEvaluator breaks when using custom datasets with "info" and "licenses" fields removed

Author: TechFusionHubCreated Oct 3, 2025Updated Oct 3, 2025

Description

I have been training a custom dataset (license plates) with YOLOX (latest from GitHub). During training, evaluation (COCOEvaluator) was consistently failing or returning empty results.

After debugging, I found the root cause:

In COCODataset (yolox/data/datasets/coco.py), the helper remove_useless_info() removes the top-level info and licenses keys from the COCO dataset for memory saving.

In COCOEvaluator (yolox/evaluators/coco_evaluator.py), the code still assumes that info and licenses are present in the dataset. This mismatch leads to evaluator crashes or broken AP/AR reporting.

This explains why evaluation was not working in my setup for weeks, even though annotations and labels were correct.

Example from yolox.exp import get_exp exp = get_exp("exps/custom/smallobj_yolox_tiny.py", None) evaluator = exp.get_evaluator(batch_size=2, is_distributed=False)

-> AttributeError or missing fields in COCO dataset

Logs AttributeError: 'COCOEvaluator' object has no attribute 'coco' or KeyError: 'info'

Expected Behavior

COCOEvaluator should not require info or licenses fields, since they are explicitly removed by the dataset loader.

Proposed Fix

In COCOEvaluator.evaluate_prediction, use only the necessary fields (images, annotations, categories). Do not assume info or licenses are present.

For example:

Current (breaks if info/licenses are missing)

cat_ids = list(cocoGt.cats.keys()) cat_names = [cocoGt.cats[catId]['name'] for catId in sorted(cat_ids)]

Should work without info/licenses

if "categories" in cocoGt.dataset: cat_ids = list(cocoGt.cats.keys()) cat_names = [cocoGt.cats[catId]["name"] for catId in sorted(cat_ids)]

Environment

Python 3.10

CUDA 12.1

PyTorch 2.4.1

YOLOX (current master)

Custom dataset in COCO format (valid JSON with images, annotations, categories, info, licenses)

Impact

This bug causes COCOEvaluator to fail or silently produce wrong results for custom datasets, especially when following the default pipeline (remove_useless_info).

Source: Megvii-BaseDetection/YOLOX