{"record":{"id":"6f41506975d6edce","repo":"open-mmlab/mmdetection","slug":"no-prediction-for-the-image-with-id-img-id","errorCode":null,"errorMessage":"no prediction for the image with id: {img_id}","messagePattern":"no prediction for the image with id: (.+?)","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"mmdet/evaluation/metrics/coco_panoptic_metric.py","lineNumber":503,"sourceCode":"                return dict()\n\n            imgs = self._coco_api.imgs\n            gt_json = self._coco_api.img_ann_map\n            gt_json = [{\n                'image_id': k,\n                'segments_info': v,\n                'file_name': imgs[k]['segm_file']\n            } for k, v in gt_json.items()]\n            pred_json = load(json_filename)\n            pred_json = dict(\n                (el['image_id'], el) for el in pred_json['annotations'])\n\n            # match the gt_anns and pred_anns in the same image\n            matched_annotations_list = []\n            for gt_ann in gt_json:\n                img_id = gt_ann['image_id']\n                if img_id not in pred_json.keys():\n                    raise Exception('no prediction for the image'\n                                    ' with id: {}'.format(img_id))\n                matched_annotations_list.append((gt_ann, pred_json[img_id]))\n\n            pq_stat = pq_compute_multi_core(\n                matched_annotations_list,\n                gt_folder,\n                pred_folder,\n                self.categories,\n                backend_args=self.backend_args,\n                nproc=self.nproc)\n\n        else:\n            # aggregate the results generated in process\n            if self._coco_api is None:\n                categories = dict()\n                for id, name in enumerate(self.dataset_meta['classes']):\n                    isthing = 1 if name in self.dataset_meta[\n                        'thing_classes'] else 0","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/evaluation/metrics/coco_panoptic_metric.py#L485-L521","documentation":"CocoPanopticMetric.compute_metrics pairs each ground-truth annotation with predictions by image_id; if a ground-truth image id has no matching entry in the prediction json, it raises a generic Exception 'no prediction for the image with id: ...'. pq_compute_multi_core requires matched (gt, pred) pairs for every image, so a missing prediction is fatal rather than counted as zero PQ.","triggerScenarios":"Running panoptic eval when the dumped predictions json lacks some image ids present in the GT annotation file — e.g. results dumped from a subset of images, an interrupted dump, mismatched ann_file vs. prediction folder, or predictions filtered out (empty pred for an image not written).","commonSituations":"Evaluating on a partial results file (resume/re-run of DumpDetResults offline eval); GT json regenerated with extra images; test set and ann_file out of sync; score_thr filtering removing all predictions so the image is never dumped.","solutions":["Ensure the prediction json covers every image_id in the GT ann_file (dump predictions for the full test set)","Verify ann_file, gt folder and the prediction file come from the same dataset split","If some images legitimately have no predictions, ensure the dump step still writes an empty prediction entry for those image ids"],"exampleFix":"# before: offline eval with partial predictions\npython tools/test.py cfg.py results.pkl --cfg-options test_evaluator.ann_file=ann.json\n# after: dump for the FULL test set, then eval with the matching json\npython tools/test.py cfg.py ckpt.pth --out results.pkl  # complete dump first","handlingStrategy":"validation","validationCode":"gt_ids = {ann['image_id'] for ann in gt_json['annotations'] if 'segments_info' in ann} if False else {a['image_id'] for a in gt_json.get('annotations', [])}\n# simpler: before eval, compare id sets\ngt_ids = {im['id'] for im in gt_json['images']}\npred_ids = set(pred_json.keys())\nmissing = gt_ids - pred_ids\nassert not missing, f'predictions missing image ids: {sorted(missing)[:5]}...'","typeGuard":"def predictions_cover_gt(gt_image_ids: set, pred_json: dict) -> bool:\n    return gt_image_ids.issubset(pred_json.keys())","tryCatchPattern":"try:\n    evaluator.compute_metrics(results)\nexcept Exception as e:\n    if 'no prediction for the image' in str(e):\n        missing = gt_ids - set(pred_json.keys())\n        raise RuntimeError(f're-dump predictions; missing ids: {sorted(missing)[:10]}') from e\n    raise","preventionTips":["Always dump predictions for the complete test split before offline eval","Regenerate prediction files whenever ann_file changes","Add a pre-eval assertion comparing gt and prediction image id sets"],"tags":["mmdetection","panoptic-segmentation","pq","data-mismatch"],"backgroundTag":"gt-prediction-id-mismatch","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}