{"record":{"id":"cf32216f1fc685da","repo":"tensorflow/models","slug":"number-of-sides-is-incorrect","errorCode":null,"errorMessage":"Number of sides is incorrect.","messagePattern":"Number of sides is incorrect\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/modeling/layers/detection_generator.py","lineNumber":649,"sourceCode":"      `valid_detections` boxes are valid detections.\n\n  Raises:\n    ValueError if inputs shapes are not valid.\n  \"\"\"\n  one = tf.constant(1, dtype=scores.dtype)\n  with tf.name_scope('generate_detections'):\n    batch_size, num_box_classes, box_locations, sides = (\n        boxes.get_shape().as_list()\n    )\n    if batch_size is None:\n      batch_size = tf.shape(boxes)[0]\n    _, num_classes, locations = scores.get_shape().as_list()\n    if num_box_classes != 1 and num_box_classes != num_classes:\n      raise ValueError('Boxes should have either 1 class or same as scores.')\n    if locations != box_locations:\n      raise ValueError('Number of locations is different.')\n    if sides != 4:\n      raise ValueError('Number of sides is incorrect.')\n    # Selects pre_nms_score_threshold scores before NMS.\n    boxes, scores = box_ops.filter_boxes_by_scores(\n        boxes, scores, min_score_threshold=pre_nms_score_threshold\n    )\n\n    # EdgeTPU-friendly class-wise NMS, -1 for invalid.\n    indices = edgetpu.non_max_suppression_padded(\n        boxes,\n        scores,\n        max_num_detections,\n        iou_threshold=nms_iou_threshold,\n        refinements=refinements,\n    )\n    # Gather NMS-ed boxes and scores.\n    safe_indices = tf.nn.relu(indices)  # 0 for invalid\n    invalid_detections = safe_indices - indices  # 1 for invalid, 0 for valid\n    valid_detections = one - invalid_detections  # 0 for invalid, 1 for valid\n    safe_indices = tf.cast(safe_indices, tf.int32)","sourceCodeStart":631,"sourceCodeEnd":667,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/modeling/layers/detection_generator.py#L631-L667","documentation":"Error \"Number of sides is incorrect.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/modeling/layers/detection_generator.py:649 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make the last dimension of boxes equal to 4 times the number of classes (or 4 for class-agnostic boxes).","Check the box encoding: each box needs exactly 4 coordinates [y1, x1, y2, x2]."],"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"}