{
  "id": 167954,
  "title": "Can any one offer some help?",
  "url": "/competitions/global-wheat-detection/discussion/167954",
  "author_name": "",
  "post_date": "2020-07-18T13:54:44.442806200Z",
  "votes": 1,
  "comment_count": 10,
  "views": 0,
  "content": "<p>I encounter submission error with this notebook.\nI am very confused because I have the right predicted bounding boxes there.\nBelow is my notebook:\n<a href=\"https://www.kaggle.com/chrisstan/yolov4-inference?scriptVersionId=39017659\">https://www.kaggle.com/chrisstan/yolov4-inference?scriptVersionId=39017659</a></p>",
  "messages": [
    {
      "id": "934506",
      "postDate": "07/18/2020 13:54:44",
      "content": "<p>I encounter submission error with this notebook.\nI am very confused because I have the right predicted bounding boxes there.\nBelow is my notebook:\n<a href=\"https://www.kaggle.com/chrisstan/yolov4-inference?scriptVersionId=39017659\">https://www.kaggle.com/chrisstan/yolov4-inference?scriptVersionId=39017659</a></p>",
      "rawMarkdown": "I encounter submission error with this notebook.\nI am very confused because I have the right predicted bounding boxes there.\nBelow is my notebook:\nhttps://www.kaggle.com/chrisstan/yolov4-inference?scriptVersionId=39017659",
      "votes": null
    },
    {
      "id": "935492",
      "postDate": "07/19/2020 12:42:42",
      "content": "<p>Not a solution but I was looking into your notebook and noticed although you have set your YoloV4 weights dataset private you copy those in the output folder resulting in it becoming publicly visible/available.</p>\n\n<p>It would be a shame if some free loaders took advantage of this mistake. Please look into this issue and maybe setup a new revised notebook.</p>",
      "rawMarkdown": "Not a solution but I was looking into your notebook and noticed although you have set your YoloV4 weights dataset private you copy those in the output folder resulting in it becoming publicly visible/available.\n\nIt would be a shame if some free loaders took advantage of this mistake. Please look into this issue and maybe setup a new revised notebook.",
      "votes": null
    },
    {
      "id": "935990",
      "postDate": "07/19/2020 21:44:05",
      "content": "<p>Thank for your suggestion.\nI have fixed it.</p>",
      "rawMarkdown": "Thank for your suggestion.\nI have fixed it.",
      "votes": null
    },
    {
      "id": "936270",
      "postDate": "07/20/2020 05:43:12",
      "content": "<p>Your code looks similar to this so follow below solution-<br>\n<a href=\"https://www.kaggle.com/c/global-wheat-detection/discussion/168179\" target=\"_blank\">https://www.kaggle.com/c/global-wheat-detection/discussion/168179</a></p>",
      "rawMarkdown": "Your code looks similar to this so follow below solution-\nhttps://www.kaggle.com/c/global-wheat-detection/discussion/168179",
      "votes": null
    },
    {
      "id": "936780",
      "postDate": "07/20/2020 14:20:02",
      "content": "<p>I tried like this and still failed..\n```python\nresults = []</p>\n\n<p>for images, image_ids in data_loader:\n    predictions = make_tta_predictions(images)\n    try:\n        for i, image in enumerate(images):</p>\n\n<pre><code>        boxes, scores, labels = run_wbf(predictions, image_index=i)\n        boxes = (boxes*(1024 / 704)).round().astype(np.int32).clip(min=0, max=1023)\n        image_id = image_ids[i]\n\n        boxes[:, 2] = boxes[:, 2] - boxes[:, 0]\n        boxes[:, 3] = boxes[:, 3] - boxes[:, 1]\n\n        result = {\n            'image_id': image_id,\n            'PredictionString': format_prediction_string(boxes, scores)\n        }\n        results.append(result)\nexcept:\n    result = {\n        'image_id': image_id,\n        'PredictionString': ''\n    }\n    results.append(result)\n</code></pre>\n\n<p>```</p>",
      "rawMarkdown": "I tried like this and still failed..\n```python\nresults = []\n\nfor images, image_ids in data_loader:\n    predictions = make_tta_predictions(images)\n    try:\n        for i, image in enumerate(images):\n\n            boxes, scores, labels = run_wbf(predictions, image_index=i)\n            boxes = (boxes*(1024 / 704)).round().astype(np.int32).clip(min=0, max=1023)\n            image_id = image_ids[i]\n\n            boxes[:, 2] = boxes[:, 2] - boxes[:, 0]\n            boxes[:, 3] = boxes[:, 3] - boxes[:, 1]\n\n            result = {\n                'image_id': image_id,\n                'PredictionString': format_prediction_string(boxes, scores)\n            }\n            results.append(result)\n    except:\n        result = {\n            'image_id': image_id,\n            'PredictionString': ''\n        }\n        results.append(result)\n```",
      "votes": null
    },
    {
      "id": "936856",
      "postDate": "07/20/2020 14:59:57",
      "content": "<p>Check box length also like below-<br>\n<code>if len(boxes)&gt;0:\n        result = {\n       'image_id': images_info['filename'][:-4],\n       'PredictionString': format_prediction_string(boxes, scores)}\n    else:\n        result = {\n       'image_id': images_info['filename'][:-4],\n       'PredictionString': ''}\n    results.append(result)</code></p>\n<p>And also put your <code>predictions = make_tta_predictions(images)</code> inside the try block.</p>",
      "rawMarkdown": "Check box length also like below-\n`if len(boxes)&gt;0:\n        result = {\n       'image_id': images_info['filename'][:-4],\n       'PredictionString': format_prediction_string(boxes, scores)}\n    else:\n        result = {\n       'image_id': images_info['filename'][:-4],\n       'PredictionString': ''}\n    results.append(result)`\n\nAnd also put your `predictions = make_tta_predictions(images)` inside the try block.",
      "votes": null
    },
    {
      "id": "936864",
      "postDate": "07/20/2020 15:03:23",
      "content": "<p>Just a wild guess but some non 704 sized image maybe causing an error in your <code>make_tta_predictions(images)</code>\nWe've too screwed a lot of our submissions over such rogue images which managed to reach the model input through some loophole in our code.</p>\n\n<p>Try copying all the test images (~1200 during submission) from the input folder to the output folder (kaggle/working/) and resize them all to your desired image size (704) right away.\nFeed this new test directory to your test loader function and see if the error still persists.</p>\n\n<p>Or just put a lazy condition like \n<code>if image.shape[0] != 704 or image.shape[1] != 704:    image=cv2.resize(image, (704,704))\npredictions = make_tta_predictions(images)</code></p>\n\n<p>You can also locally test this theory of mine by taking some ~1000 train images as test images with weird shapes (take a few greater than 1024 some lesser than it and maybe try rectangle images etc.) and run your inference with them.</p>\n\n<p>See if this helps.</p>",
      "rawMarkdown": "Just a wild guess but some non 704 sized image maybe causing an error in your `make_tta_predictions(images)`\nWe've too screwed a lot of our submissions over such rogue images which managed to reach the model input through some loophole in our code.\n\nTry copying all the test images (~1200 during submission) from the input folder to the output folder (kaggle/working/) and resize them all to your desired image size (704) right away.\nFeed this new test directory to your test loader function and see if the error still persists.\n\nOr just put a lazy condition like \n`if image.shape[0] != 704 or image.shape[1] != 704:    image=cv2.resize(image, (704,704))\npredictions = make_tta_predictions(images)`\n\nYou can also locally test this theory of mine by taking some ~1000 train images as test images with weird shapes (take a few greater than 1024 some lesser than it and maybe try rectangle images etc.) and run your inference with them.\n\nSee if this helps.",
      "votes": null
    },
    {
      "id": "937200",
      "postDate": "07/20/2020 19:56:21",
      "content": "<p>Hi, which submission error are you getting? I can only speak from my experience:\n1. First I got an \"Submission CSV not found\" error. This seems to have been caused by me having an additional folder in my working directory, so now I delete everything except submission.csv and the notebook. It could also have been caused by me copying too much data into the working directory, because I was copying the whole training set. I think that might have been too much (first competition errors).\n2. I then got a \"Submission Scoring Error\". To solve this I first added a cell copying sample_submission.csv as submision.csv into the working directory --&gt; no error, so I knew that the error was not caused by my code and that the system also accepts incomplete submissions without error.\nThen I did the same for a submission made by my code on only the 10 public images --&gt; error. So I knew that the error was caused by the formating of the file containing only the 10 public images. After schecking everything I could think of (double spaces, etc.), I went to <a href=\"https://regex101.com/\">https://regex101.com/</a> copied in the whole submission file and used the regex r\"0.\\d+ \\d+ \\d+ \\d+ \\d+\" to match all of my output. I saw that a few little parts did not match because the submission did not contain all 4 coordinates, only 3 in some rare cases. I then corrected the problem and it works now.\nHope this helps!\nEdit: I saw that you already fixed it. But maybe someone else will find this.</p>",
      "rawMarkdown": "Hi, which submission error are you getting? I can only speak from my experience:\n1. First I got an \"Submission CSV not found\" error. This seems to have been caused by me having an additional folder in my working directory, so now I delete everything except submission.csv and the notebook. It could also have been caused by me copying too much data into the working directory, because I was copying the whole training set. I think that might have been too much (first competition errors).\n2. I then got a \"Submission Scoring Error\". To solve this I first added a cell copying sample_submission.csv as submision.csv into the working directory --&gt; no error, so I knew that the error was not caused by my code and that the system also accepts incomplete submissions without error.\nThen I did the same for a submission made by my code on only the 10 public images --&gt; error. So I knew that the error was caused by the formating of the file containing only the 10 public images. After schecking everything I could think of (double spaces, etc.), I went to https://regex101.com/ copied in the whole submission file and used the regex r\"0.\\d+ \\d+ \\d+ \\d+ \\d+\" to match all of my output. I saw that a few little parts did not match because the submission did not contain all 4 coordinates, only 3 in some rare cases. I then corrected the problem and it works now.\nHope this helps!\nEdit: I saw that you already fixed it. But maybe someone else will find this.",
      "votes": null
    },
    {
      "id": "937320",
      "postDate": "07/20/2020 23:39:17",
      "content": "<p>Now it can submit! Thanks!</p>",
      "rawMarkdown": "Now it can submit! Thanks!",
      "votes": null
    },
    {
      "id": "937321",
      "postDate": "07/20/2020 23:39:32",
      "content": "<p>Now it can work! Thanks!!!</p>",
      "rawMarkdown": "Now it can work! Thanks!!!",
      "votes": null
    },
    {
      "id": "937330",
      "postDate": "07/20/2020 23:56:42",
      "content": "<p>Now it work! Thanks !!!!!</p>",
      "rawMarkdown": "Now it work! Thanks !!!!!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 936270,
      "author_name": "iamprateek",
      "author_url": "",
      "post_date": "07/20/2020 05:43:12",
      "content": "<p>Your code looks similar to this so follow below solution-<br>\n<a href=\"https://www.kaggle.com/c/global-wheat-detection/discussion/168179\" target=\"_blank\">https://www.kaggle.com/c/global-wheat-detection/discussion/168179</a></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 936780,
      "author_name": "chrisstan",
      "author_url": "",
      "post_date": "07/20/2020 14:20:02",
      "content": "<p>I tried like this and still failed..\n```python\nresults = []</p>\n\n<p>for images, image_ids in data_loader:\n    predictions = make_tta_predictions(images)\n    try:\n        for i, image in enumerate(images):</p>\n\n<pre><code>        boxes, scores, labels = run_wbf(predictions, image_index=i)\n        boxes = (boxes*(1024 / 704)).round().astype(np.int32).clip(min=0, max=1023)\n        image_id = image_ids[i]\n\n        boxes[:, 2] = boxes[:, 2] - boxes[:, 0]\n        boxes[:, 3] = boxes[:, 3] - boxes[:, 1]\n\n        result = {\n            'image_id': image_id,\n            'PredictionString': format_prediction_string(boxes, scores)\n        }\n        results.append(result)\nexcept:\n    result = {\n        'image_id': image_id,\n        'PredictionString': ''\n    }\n    results.append(result)\n</code></pre>\n\n<p>```</p>",
      "votes": null,
      "replies": [
        {
          "id": 936856,
          "author_name": "iamprateek",
          "author_url": "",
          "post_date": "07/20/2020 14:59:57",
          "content": "<p>Check box length also like below-<br>\n<code>if len(boxes)&gt;0:\n        result = {\n       'image_id': images_info['filename'][:-4],\n       'PredictionString': format_prediction_string(boxes, scores)}\n    else:\n        result = {\n       'image_id': images_info['filename'][:-4],\n       'PredictionString': ''}\n    results.append(result)</code></p>\n<p>And also put your <code>predictions = make_tta_predictions(images)</code> inside the try block.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 937321,
          "author_name": "chrisstan",
          "author_url": "",
          "post_date": "07/20/2020 23:39:32",
          "content": "<p>Now it can work! Thanks!!!</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 936864,
      "author_name": "ii5m0k3ii",
      "author_url": "",
      "post_date": "07/20/2020 15:03:23",
      "content": "<p>Just a wild guess but some non 704 sized image maybe causing an error in your <code>make_tta_predictions(images)</code>\nWe've too screwed a lot of our submissions over such rogue images which managed to reach the model input through some loophole in our code.</p>\n\n<p>Try copying all the test images (~1200 during submission) from the input folder to the output folder (kaggle/working/) and resize them all to your desired image size (704) right away.\nFeed this new test directory to your test loader function and see if the error still persists.</p>\n\n<p>Or just put a lazy condition like \n<code>if image.shape[0] != 704 or image.shape[1] != 704:    image=cv2.resize(image, (704,704))\npredictions = make_tta_predictions(images)</code></p>\n\n<p>You can also locally test this theory of mine by taking some ~1000 train images as test images with weird shapes (take a few greater than 1024 some lesser than it and maybe try rectangle images etc.) and run your inference with them.</p>\n\n<p>See if this helps.</p>",
      "votes": null,
      "replies": [
        {
          "id": 937320,
          "author_name": "chrisstan",
          "author_url": "",
          "post_date": "07/20/2020 23:39:17",
          "content": "<p>Now it can submit! Thanks!</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 935492,
      "author_name": "ii5m0k3ii",
      "author_url": "",
      "post_date": "07/19/2020 12:42:42",
      "content": "<p>Not a solution but I was looking into your notebook and noticed although you have set your YoloV4 weights dataset private you copy those in the output folder resulting in it becoming publicly visible/available.</p>\n\n<p>It would be a shame if some free loaders took advantage of this mistake. Please look into this issue and maybe setup a new revised notebook.</p>",
      "votes": null,
      "replies": [
        {
          "id": 935990,
          "author_name": "chrisstan",
          "author_url": "",
          "post_date": "07/19/2020 21:44:05",
          "content": "<p>Thank for your suggestion.\nI have fixed it.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 937200,
      "author_name": "johannesillerhaus",
      "author_url": "",
      "post_date": "07/20/2020 19:56:21",
      "content": "<p>Hi, which submission error are you getting? I can only speak from my experience:\n1. First I got an \"Submission CSV not found\" error. This seems to have been caused by me having an additional folder in my working directory, so now I delete everything except submission.csv and the notebook. It could also have been caused by me copying too much data into the working directory, because I was copying the whole training set. I think that might have been too much (first competition errors).\n2. I then got a \"Submission Scoring Error\". To solve this I first added a cell copying sample_submission.csv as submision.csv into the working directory --&gt; no error, so I knew that the error was not caused by my code and that the system also accepts incomplete submissions without error.\nThen I did the same for a submission made by my code on only the 10 public images --&gt; error. So I knew that the error was caused by the formating of the file containing only the 10 public images. After schecking everything I could think of (double spaces, etc.), I went to <a href=\"https://regex101.com/\">https://regex101.com/</a> copied in the whole submission file and used the regex r\"0.\\d+ \\d+ \\d+ \\d+ \\d+\" to match all of my output. I saw that a few little parts did not match because the submission did not contain all 4 coordinates, only 3 in some rare cases. I then corrected the problem and it works now.\nHope this helps!\nEdit: I saw that you already fixed it. But maybe someone else will find this.</p>",
      "votes": null,
      "replies": [
        {
          "id": 937330,
          "author_name": "chrisstan",
          "author_url": "",
          "post_date": "07/20/2020 23:56:42",
          "content": "<p>Now it work! Thanks !!!!!</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "934506": "I encounter submission error with this notebook.\nI am very confused because I have the right predicted bounding boxes there.\nBelow is my notebook:\nhttps://www.kaggle.com/chrisstan/yolov4-inference?scriptVersionId=39017659",
    "935492": "Not a solution but I was looking into your notebook and noticed although you have set your YoloV4 weights dataset private you copy those in the output folder resulting in it becoming publicly visible/available.\n\nIt would be a shame if some free loaders took advantage of this mistake. Please look into this issue and maybe setup a new revised notebook.",
    "935990": "Thank for your suggestion.\nI have fixed it.",
    "936270": "Your code looks similar to this so follow below solution-\nhttps://www.kaggle.com/c/global-wheat-detection/discussion/168179",
    "936780": "I tried like this and still failed..\n```python\nresults = []\n\nfor images, image_ids in data_loader:\n    predictions = make_tta_predictions(images)\n    try:\n        for i, image in enumerate(images):\n\n            boxes, scores, labels = run_wbf(predictions, image_index=i)\n            boxes = (boxes*(1024 / 704)).round().astype(np.int32).clip(min=0, max=1023)\n            image_id = image_ids[i]\n\n            boxes[:, 2] = boxes[:, 2] - boxes[:, 0]\n            boxes[:, 3] = boxes[:, 3] - boxes[:, 1]\n\n            result = {\n                'image_id': image_id,\n                'PredictionString': format_prediction_string(boxes, scores)\n            }\n            results.append(result)\n    except:\n        result = {\n            'image_id': image_id,\n            'PredictionString': ''\n        }\n        results.append(result)\n```",
    "936856": "Check box length also like below-\n`if len(boxes)&gt;0:\n        result = {\n       'image_id': images_info['filename'][:-4],\n       'PredictionString': format_prediction_string(boxes, scores)}\n    else:\n        result = {\n       'image_id': images_info['filename'][:-4],\n       'PredictionString': ''}\n    results.append(result)`\n\nAnd also put your `predictions = make_tta_predictions(images)` inside the try block.",
    "936864": "Just a wild guess but some non 704 sized image maybe causing an error in your `make_tta_predictions(images)`\nWe've too screwed a lot of our submissions over such rogue images which managed to reach the model input through some loophole in our code.\n\nTry copying all the test images (~1200 during submission) from the input folder to the output folder (kaggle/working/) and resize them all to your desired image size (704) right away.\nFeed this new test directory to your test loader function and see if the error still persists.\n\nOr just put a lazy condition like \n`if image.shape[0] != 704 or image.shape[1] != 704:    image=cv2.resize(image, (704,704))\npredictions = make_tta_predictions(images)`\n\nYou can also locally test this theory of mine by taking some ~1000 train images as test images with weird shapes (take a few greater than 1024 some lesser than it and maybe try rectangle images etc.) and run your inference with them.\n\nSee if this helps.",
    "937200": "Hi, which submission error are you getting? I can only speak from my experience:\n1. First I got an \"Submission CSV not found\" error. This seems to have been caused by me having an additional folder in my working directory, so now I delete everything except submission.csv and the notebook. It could also have been caused by me copying too much data into the working directory, because I was copying the whole training set. I think that might have been too much (first competition errors).\n2. I then got a \"Submission Scoring Error\". To solve this I first added a cell copying sample_submission.csv as submision.csv into the working directory --&gt; no error, so I knew that the error was not caused by my code and that the system also accepts incomplete submissions without error.\nThen I did the same for a submission made by my code on only the 10 public images --&gt; error. So I knew that the error was caused by the formating of the file containing only the 10 public images. After schecking everything I could think of (double spaces, etc.), I went to https://regex101.com/ copied in the whole submission file and used the regex r\"0.\\d+ \\d+ \\d+ \\d+ \\d+\" to match all of my output. I saw that a few little parts did not match because the submission did not contain all 4 coordinates, only 3 in some rare cases. I then corrected the problem and it works now.\nHope this helps!\nEdit: I saw that you already fixed it. But maybe someone else will find this.",
    "937320": "Now it can submit! Thanks!",
    "937321": "Now it can work! Thanks!!!",
    "937330": "Now it work! Thanks !!!!!"
  },
  "source": "meta"
}