{"record":{"id":"7d5d0b6e860eb014","repo":"tensorflow/models","slug":"if-not-using-tflite-custom-nms-use-class-agnosti","errorCode":null,"errorMessage":"If not using TFLite custom NMS, `use_class_agnostic_nms` can only be enabled for NMS v2 for now, but NMS {} is used! If you are using TFLite NMS, please configure TFLite custom NMS for class-agnostic NMS.","messagePattern":"If not using TFLite custom NMS, `use_class_agnostic_nms` can only be enabled for NMS v2 for now, but NMS (.+?) is used! If you are using TFLite NMS, please configure TFLite custom NMS for class-agnostic NMS\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/modeling/layers/detection_generator.py","lineNumber":1191,"sourceCode":"        if == 0, AP is reduced 1.0%, AR is reduced 5% on COCO\n        if == 1, AP is reduced 0.2%, AR is reduced 2% on COCO\n        if == 2, AP is reduced <0.1%, AR is reduced <1% on COCO\n      return_decoded: A `bool` of whether to return decoded boxes before NMS\n        regardless of whether `apply_nms` is True or not.\n      use_class_agnostic_nms: A `bool` of whether non max suppression is\n        operated on all the boxes using max scores across all classes.\n      box_coder_weights: An optional `list` of 4 positive floats to scale y, x,\n        h, and w when encoding box coordinates. If set to None, does not perform\n        scaling. For Faster RCNN, the open-source implementation recommends\n        using [10.0, 10.0, 5.0, 5.0].\n      **kwargs: Additional keyword arguments passed to Layer.\n\n    Raises:\n      ValueError: If `use_class_agnostic_nms` is required by `nms_version` is\n      not specified as `v2`.\n    \"\"\"\n    if use_class_agnostic_nms and nms_version != 'v2':\n      raise ValueError(\n          'If not using TFLite custom NMS, `use_class_agnostic_nms` can only be'\n          ' enabled for NMS v2 for now, but NMS {} is used! If you are using'\n          ' TFLite NMS, please configure TFLite custom NMS for class-agnostic'\n          ' NMS.'.format(nms_version)\n      )\n    self._config_dict = {\n        'apply_nms': apply_nms,\n        'pre_nms_top_k': pre_nms_top_k,\n        'pre_nms_score_threshold': pre_nms_score_threshold,\n        'nms_iou_threshold': nms_iou_threshold,\n        'max_num_detections': max_num_detections,\n        'nms_version': nms_version,\n        'use_cpu_nms': use_cpu_nms,\n        'soft_nms_sigma': soft_nms_sigma,\n        'return_decoded': return_decoded,\n        'use_class_agnostic_nms': use_class_agnostic_nms,\n        'box_coder_weights': box_coder_weights,\n    }","sourceCodeStart":1173,"sourceCodeEnd":1209,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/modeling/layers/detection_generator.py#L1173-L1209","documentation":"Error \"If not using TFLite custom NMS, `use_class_agnostic_nms` can only be enabled for NMS v2 for now, but NMS {} is used! If you are using TFLite NMS, please configure TFLite custom NMS for class-agnostic NMS.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/modeling/layers/detection_generator.py:1191 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set nms_version to 2 when enabling use_class_agnostic_nms without TFLite custom NMS.","If deploying to TFLite, configure the TFLite custom NMS for class-agnostic NMS instead."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}