{
  "id": 305838,
  "title": "Tuple Index out of Range for non_max_suppression Function",
  "url": "/competitions/tensorflow-great-barrier-reef/discussion/305838",
  "author_name": "Dino Wun",
  "post_date": "2022-02-07T06:15:52.119000",
  "votes": 5,
  "comment_count": 0,
  "views": 0,
  "content": "<p>After solving the bboxes_type problem over YOLOR predictions, I was ready to roll towards the final part, submitting predictions to this code competition. But, there is one thing that blocked me from doing that, running towards the final exception. The cause of it relied on the segment of the submission code cell over here:</p>\n<pre><code>bboxes_3, scoress, _ = predict_img(model, image_np[:,:,::-1], img_size, conf_thres = CONF, iou_thres = IOU, device = device)\n</code></pre>\n<p>When ran, the <code>predict_img()</code> function was called, and the segment of the <code>predict_img()</code> function over here:</p>\n<pre><code>pred = non_max_suppression(pred, conf_thres=conf_thres, iou_thres=iou_thres, merge=False, classes=None, agnostic=False)\n</code></pre>\n<p>Which the <code>pred</code> variable was defined, but what about the <code>non_max_suppression()</code> function? It got an error, an IndexError. Inside the <code>non_max_suppression()</code> function, the fragment of this code cell explains the cause of that over here:</p>\n<pre><code>nc = prediction[0].shape[1] - 5  # number of classes\n</code></pre>\n<p>That explains how my <code>pred</code> variable contained an \"out-of-range\" <code>img</code> variable tuple index. Can you explain the solution to squash that error, one final time?</p>",
  "messages": [
    {
      "id": 1679293,
      "postDate": "2022-02-07T06:15:52.120Z",
      "content": "<p>After solving the bboxes_type problem over YOLOR predictions, I was ready to roll towards the final part, submitting predictions to this code competition. But, there is one thing that blocked me from doing that, running towards the final exception. The cause of it relied on the segment of the submission code cell over here:</p>\n<pre><code>bboxes_3, scoress, _ = predict_img(model, image_np[:,:,::-1], img_size, conf_thres = CONF, iou_thres = IOU, device = device)\n</code></pre>\n<p>When ran, the <code>predict_img()</code> function was called, and the segment of the <code>predict_img()</code> function over here:</p>\n<pre><code>pred = non_max_suppression(pred, conf_thres=conf_thres, iou_thres=iou_thres, merge=False, classes=None, agnostic=False)\n</code></pre>\n<p>Which the <code>pred</code> variable was defined, but what about the <code>non_max_suppression()</code> function? It got an error, an IndexError. Inside the <code>non_max_suppression()</code> function, the fragment of this code cell explains the cause of that over here:</p>\n<pre><code>nc = prediction[0].shape[1] - 5  # number of classes\n</code></pre>\n<p>That explains how my <code>pred</code> variable contained an \"out-of-range\" <code>img</code> variable tuple index. Can you explain the solution to squash that error, one final time?</p>",
      "rawMarkdown": "After solving the bboxes_type problem over YOLOR predictions, I was ready to roll towards the final part, submitting predictions to this code competition. But, there is one thing that blocked me from doing that, running towards the final exception. The cause of it relied on the segment of the submission code cell over here:\n```\nbboxes_3, scoress, _ = predict_img(model, image_np[:,:,::-1], img_size, conf_thres = CONF, iou_thres = IOU, device = device)\n```\nWhen ran, the `predict_img()` function was called, and the segment of the `predict_img()` function over here:\n```\npred = non_max_suppression(pred, conf_thres=conf_thres, iou_thres=iou_thres, merge=False, classes=None, agnostic=False)\n```\nWhich the `pred` variable was defined, but what about the `non_max_suppression()` function? It got an error, an IndexError. Inside the `non_max_suppression()` function, the fragment of this code cell explains the cause of that over here:\n```\nnc = prediction[0].shape[1] - 5  # number of classes\n```\nThat explains how my `pred` variable contained an \"out-of-range\" `img` variable tuple index. Can you explain the solution to squash that error, one final time?",
      "votes": 5
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "1679293": "After solving the bboxes_type problem over YOLOR predictions, I was ready to roll towards the final part, submitting predictions to this code competition. But, there is one thing that blocked me from doing that, running towards the final exception. The cause of it relied on the segment of the submission code cell over here:\n```\nbboxes_3, scoress, _ = predict_img(model, image_np[:,:,::-1], img_size, conf_thres = CONF, iou_thres = IOU, device = device)\n```\nWhen ran, the `predict_img()` function was called, and the segment of the `predict_img()` function over here:\n```\npred = non_max_suppression(pred, conf_thres=conf_thres, iou_thres=iou_thres, merge=False, classes=None, agnostic=False)\n```\nWhich the `pred` variable was defined, but what about the `non_max_suppression()` function? It got an error, an IndexError. Inside the `non_max_suppression()` function, the fragment of this code cell explains the cause of that over here:\n```\nnc = prediction[0].shape[1] - 5  # number of classes\n```\nThat explains how my `pred` variable contained an \"out-of-range\" `img` variable tuple index. Can you explain the solution to squash that error, one final time?"
  }
}