{"record":{"id":"572945d8d0d6364e","repo":"WZMIAOMIAO/deep-learning-for-image-processing","slug":"no-proposal-boxes-available-for-one-of-the-images","errorCode":null,"errorMessage":"No proposal boxes available for one of the images during training","messagePattern":"No proposal boxes available for one of the images during training","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pytorch_object_detection/faster_rcnn/network_files/det_utils.py","lineNumber":321,"sourceCode":"        计算anchors与每个gtboxes匹配的iou最大值，并记录索引，\n        iou<low_threshold索引值为-1， low_threshold<=iou<high_threshold索引值为-2\n        Args:\n            match_quality_matrix (Tensor[float]): an MxN tensor, containing the\n            pairwise quality between M ground-truth elements and N predicted elements.\n\n        Returns:\n            matches (Tensor[int64]): an N tensor where N[i] is a matched gt in\n            [0, M - 1] or a negative value indicating that prediction i could not\n            be matched.\n        \"\"\"\n        if match_quality_matrix.numel() == 0:\n            # empty targets or proposals not supported during training\n            if match_quality_matrix.shape[0] == 0:\n                raise ValueError(\n                    \"No ground-truth boxes available for one of the images \"\n                    \"during training\")\n            else:\n                raise ValueError(\n                    \"No proposal boxes available for one of the images \"\n                    \"during training\")\n\n        # match_quality_matrix is M (gt) x N (predicted)\n        # Max over gt elements (dim 0) to find best gt candidate for each prediction\n        # M x N 的每一列代表一个anchors与所有gt的匹配iou值\n        # matched_vals代表每列的最大值，即每个anchors与所有gt匹配的最大iou值\n        # matches对应最大值所在的索引\n        matched_vals, matches = match_quality_matrix.max(dim=0)  # the dimension to reduce.\n        if self.allow_low_quality_matches:\n            all_matches = matches.clone()\n        else:\n            all_matches = None\n\n        # Assign candidate matches with low quality to negative (unassigned) values\n        # 计算iou小于low_threshold的索引\n        below_low_threshold = matched_vals < self.low_threshold\n        # 计算iou在low_threshold与high_threshold之间的索引值","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/WZMIAOMIAO/deep-learning-for-image-processing/blob/1ec3fe6f374fc9969973a61f819de25658595afa/pytorch_object_detection/faster_rcnn/network_files/det_utils.py#L303-L339","documentation":"The sibling case in Matcher.__call__: match_quality_matrix has zero columns (N=0) meaning no proposals/anchors were produced for an image, so raise 'No proposal boxes available...'. Assignment between GT and proposals is impossible with zero proposals, hence training aborts with this ValueError.","triggerScenarios":"RPN generates no proposals/anchors for an image — typically all anchors discarded (e.g. tiny images smaller than anchor base sizes, degenerate boxes after clipping), or an upstream filter empties the proposal list during training.","commonSituations":"Extremely small input images, wrong min_size/anchor generator config, custom backbones producing tiny feature maps, or proposal filtering removing everything before the matcher.","solutions":["Increase input image size or check transforms — images smaller than the anchor stride produce no valid anchors.","Verify rpn_anchor_generator and feature-map sizes (feature maps must be large enough for anchors).","Check min_size / RPN pre/post-nms_top_n settings aren't filtering all proposals.","Log len(proposals) per image to find which images yield zero proposals.","Ensure normalized/degenerate boxes aren't collapsing after clip_to_image/remove_small_boxes."],"exampleFix":"# before\nimages, targets = transforms(images, targets)  # tiny images shrink feature maps to zero anchors\n# after\nif any(img.shape[-1] < 32 or img.shape[-2] < 32 for img in images):\n    images = [F.interpolate(img.unsqueeze(0), size=(min(800, max(img.shape[-2], 32)), min(1333, max(img.shape[-1], 32)))).squeeze(0) for img in images]","handlingStrategy":"validation","validationCode":"assert min(img.shape[-2] for img in images) >= 32 and min(img.shape[-1] for img in images) >= 32, \"image too small: anchors may be empty\"","typeGuard":"def has_valid_proposals(proposals) -> bool:\n    return all(p.shape[0] > 0 for p in proposals)","tryCatchPattern":"try:\n    loss_dict = model(images, targets)\nexcept ValueError as e:\n    if 'proposal' in str(e):\n        print('Zero proposals: enlarge input image or fix anchor config'); continue\n    raise","preventionTips":["Keep input images larger than the anchor base size / strides","Verify feature-map sizes are non-trivial with a custom backbone","Don't over-filter proposals (min_size, score thresholds) in training","Sanity-check anchor generator coverage for small images"],"tags":["training","rpn","proposals","matcher"],"backgroundTag":"empty-proposal-boxes","analyzedSha":"1ec3fe6f374fc9969973a61f819de25658595afa","analyzedAt":"2026-08-30T09:19:11.901Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}