{
  "id": 175922,
  "title": "Would-be 39th place solution with single model (yolov4) from a first time competitor",
  "url": "/competitions/global-wheat-detection/writeups/aazz-would-be-39th-place-solution-with-single-mode",
  "author_name": "",
  "post_date": "2020-08-19T21:14:44.737Z",
  "votes": 15,
  "comment_count": 2,
  "views": 0,
  "content": "<h2>Introduction and thanks</h2>\n<p>My team used both Effdet and YOLOv4 (though our final submissions were both Effdet). I focused on YOLOv4 so I will do a bit of a write up from my side. I started the competition about 2 weeks before the end after beginning learning machine learning in March. </p>\n<p>Thanks to my team for supporting me throughout this competition even though I was underqualified and helping me debug. Thanks to Hawkey and NVNN for their YOLOv5 Pseudolabelling/OOF evaluation notebook, pabloberhauser for his notebook converting label formats to yolov4, and Mark Peng for precompiling Darknet binaries to work on the Kaggle enviornment. </p>\n<h2>Training</h2>\n<p>I used AlexeyAB's <a href=\"https://github.com/AlexeyAB/darknet\" target=\"_blank\">Darknet</a> to train. Using Colab Pro, the maximum image size I could get with reasonable speed was 704x704, batch size of 64, 32 subdivisions, and 94 epochs (6000 batches). All other parameters were the default given by Darknet, only adjusting filter, steps, etc. in order to train with 1 label. Training on Darknet was quite simple since it handles CV and augmentations automatically. However, labels need to be converted to txt files. I used <a href=\"https://www.kaggle.com/pabloberhauser/creating-label-files-for-use-in-yolov4\" target=\"_blank\">Pabloberhauser's notebook</a> to do this. This baseline alongside WBF over TTA gets a score of only about 0.7115 public and 0.6371 private. <a href=\"https://www.kaggle.com/stanleyjzheng/yolov4-wbf-inference?scriptVersionId=39789314\" target=\"_blank\">The WBF over TTA inference notebook is here</a>. I experimented lots with the training; I tried modifying anchors so that they were the same as yolov5, cutmix, but none of it worked as well as default on CV. </p>\n<h2>Pseudolabelling</h2>\n<p>I used NVNN's YOLOv5 notebook with Hawkey's OOF evaluation. For inference, I used <a href=\"https://github.com/Tianxiaomo/pytorch-YOLOv4\" target=\"_blank\">PytorchYOLOv4</a> to convert the .weights saved model generated by Darknet into a Pytorch file for inference. I had tons of issues with training pseudolabels however. PytorchYOLOv4 was not very robust, and gave me errors randomly. After a few PR and the deadline fast approaching, I tried using Darknet to train. Libcuda.so is inaccessible on Kaggle environments, so Darknet would not compile either. Many thanks for Mark Peng for precompiling Darknet for use with Kaggle. Finally, we used Darknet to train pseudolabels. </p>\n<p>The precompiled Darknet did not have OpenCV, so we could not use mosaic. Therefore, we had to be very careful with overfitting to the pseudolabels. We used the same config as the training above, but only 800 batches (12 epochs). Then, we performed bayesian optimization and TTA over WBF for our final submissions. The best submission was 0.7406 on public LB and 0.6625 on private LB. </p>\n<p><a href=\"https://www.kaggle.com/stanleyjzheng/yolov4pl-oof?scriptVersionId=40172709\" target=\"_blank\">Here is the notebook</a></p>\n<h2>Final Remarks</h2>\n<p>This methodology can definitely be improved. However, with how long it took to train a model (About 28 hours on a P100 on Colab Pro at 704x704 resolution) and the short timeline I had (2 weeks), I feel this is a pretty good solution. Once late submissions open up, I plan on testing other models as well as an ensemble with effdet. </p>\n<p>On a more personal note, this whole competition has been a long journey that has felt like ages. I'm 16, and really turned myself around at the start of quarantine to begin learning machine learning. I discovered Kaggle only 3 months ago, and was super surprised by the community; the community is so generous with sharing knowledge and code. I feel so proud of getting my first medal in my first competition. I hope this write-up can be inspiring as notebooks from the likes of Chris Deotte and Alex Shonenkov. Thanks to everyone!</p>",
  "messages": [
    {
      "id": "977985",
      "postDate": "08/19/2020 20:45:17",
      "content": "<h2>Introduction and thanks</h2>\n<p>My team used both Effdet and YOLOv4 (though our final submissions were both Effdet). I focused on YOLOv4 so I will do a bit of a write up from my side. I started the competition about 2 weeks before the end after beginning learning machine learning in March. </p>\n<p>Thanks to my team for supporting me throughout this competition even though I was underqualified and helping me debug. Thanks to Hawkey and NVNN for their YOLOv5 Pseudolabelling/OOF evaluation notebook, pabloberhauser for his notebook converting label formats to yolov4, and Mark Peng for precompiling Darknet binaries to work on the Kaggle enviornment. </p>\n<h2>Training</h2>\n<p>I used AlexeyAB's <a href=\"https://github.com/AlexeyAB/darknet\" target=\"_blank\">Darknet</a> to train. Using Colab Pro, the maximum image size I could get with reasonable speed was 704x704, batch size of 64, 32 subdivisions, and 94 epochs (6000 batches). All other parameters were the default given by Darknet, only adjusting filter, steps, etc. in order to train with 1 label. Training on Darknet was quite simple since it handles CV and augmentations automatically. However, labels need to be converted to txt files. I used <a href=\"https://www.kaggle.com/pabloberhauser/creating-label-files-for-use-in-yolov4\" target=\"_blank\">Pabloberhauser's notebook</a> to do this. This baseline alongside WBF over TTA gets a score of only about 0.7115 public and 0.6371 private. <a href=\"https://www.kaggle.com/stanleyjzheng/yolov4-wbf-inference?scriptVersionId=39789314\" target=\"_blank\">The WBF over TTA inference notebook is here</a>. I experimented lots with the training; I tried modifying anchors so that they were the same as yolov5, cutmix, but none of it worked as well as default on CV. </p>\n<h2>Pseudolabelling</h2>\n<p>I used NVNN's YOLOv5 notebook with Hawkey's OOF evaluation. For inference, I used <a href=\"https://github.com/Tianxiaomo/pytorch-YOLOv4\" target=\"_blank\">PytorchYOLOv4</a> to convert the .weights saved model generated by Darknet into a Pytorch file for inference. I had tons of issues with training pseudolabels however. PytorchYOLOv4 was not very robust, and gave me errors randomly. After a few PR and the deadline fast approaching, I tried using Darknet to train. Libcuda.so is inaccessible on Kaggle environments, so Darknet would not compile either. Many thanks for Mark Peng for precompiling Darknet for use with Kaggle. Finally, we used Darknet to train pseudolabels. </p>\n<p>The precompiled Darknet did not have OpenCV, so we could not use mosaic. Therefore, we had to be very careful with overfitting to the pseudolabels. We used the same config as the training above, but only 800 batches (12 epochs). Then, we performed bayesian optimization and TTA over WBF for our final submissions. The best submission was 0.7406 on public LB and 0.6625 on private LB. </p>\n<p><a href=\"https://www.kaggle.com/stanleyjzheng/yolov4pl-oof?scriptVersionId=40172709\" target=\"_blank\">Here is the notebook</a></p>\n<h2>Final Remarks</h2>\n<p>This methodology can definitely be improved. However, with how long it took to train a model (About 28 hours on a P100 on Colab Pro at 704x704 resolution) and the short timeline I had (2 weeks), I feel this is a pretty good solution. Once late submissions open up, I plan on testing other models as well as an ensemble with effdet. </p>\n<p>On a more personal note, this whole competition has been a long journey that has felt like ages. I'm 16, and really turned myself around at the start of quarantine to begin learning machine learning. I discovered Kaggle only 3 months ago, and was super surprised by the community; the community is so generous with sharing knowledge and code. I feel so proud of getting my first medal in my first competition. I hope this write-up can be inspiring as notebooks from the likes of Chris Deotte and Alex Shonenkov. Thanks to everyone!</p>",
      "rawMarkdown": "## Introduction and thanks\nMy team used both Effdet and YOLOv4 (though our final submissions were both Effdet). I focused on YOLOv4 so I will do a bit of a write up from my side. I started the competition about 2 weeks before the end after beginning learning machine learning in March. \n\nThanks to my team for supporting me throughout this competition even though I was underqualified and helping me debug. Thanks to Hawkey and NVNN for their YOLOv5 Pseudolabelling/OOF evaluation notebook, pabloberhauser for his notebook converting label formats to yolov4, and Mark Peng for precompiling Darknet binaries to work on the Kaggle enviornment. \n\n## Training\nI used AlexeyAB's [Darknet](https://github.com/AlexeyAB/darknet) to train. Using Colab Pro, the maximum image size I could get with reasonable speed was 704x704, batch size of 64, 32 subdivisions, and 94 epochs (6000 batches). All other parameters were the default given by Darknet, only adjusting filter, steps, etc. in order to train with 1 label. Training on Darknet was quite simple since it handles CV and augmentations automatically. However, labels need to be converted to txt files. I used [Pabloberhauser's notebook](https://www.kaggle.com/pabloberhauser/creating-label-files-for-use-in-yolov4) to do this. This baseline alongside WBF over TTA gets a score of only about 0.7115 public and 0.6371 private. [The WBF over TTA inference notebook is here](https://www.kaggle.com/stanleyjzheng/yolov4-wbf-inference?scriptVersionId=39789314). I experimented lots with the training; I tried modifying anchors so that they were the same as yolov5, cutmix, but none of it worked as well as default on CV. \n\n## Pseudolabelling\n\nI used NVNN's YOLOv5 notebook with Hawkey's OOF evaluation. For inference, I used [PytorchYOLOv4](https://github.com/Tianxiaomo/pytorch-YOLOv4) to convert the .weights saved model generated by Darknet into a Pytorch file for inference. I had tons of issues with training pseudolabels however. PytorchYOLOv4 was not very robust, and gave me errors randomly. After a few PR and the deadline fast approaching, I tried using Darknet to train. Libcuda.so is inaccessible on Kaggle environments, so Darknet would not compile either. Many thanks for Mark Peng for precompiling Darknet for use with Kaggle. Finally, we used Darknet to train pseudolabels. \n\nThe precompiled Darknet did not have OpenCV, so we could not use mosaic. Therefore, we had to be very careful with overfitting to the pseudolabels. We used the same config as the training above, but only 800 batches (12 epochs). Then, we performed bayesian optimization and TTA over WBF for our final submissions. The best submission was 0.7406 on public LB and 0.6625 on private LB. \n\n[Here is the notebook](https://www.kaggle.com/stanleyjzheng/yolov4pl-oof?scriptVersionId=40172709)\n\n## Final Remarks\n\nThis methodology can definitely be improved. However, with how long it took to train a model (About 28 hours on a P100 on Colab Pro at 704x704 resolution) and the short timeline I had (2 weeks), I feel this is a pretty good solution. Once late submissions open up, I plan on testing other models as well as an ensemble with effdet. \n\nOn a more personal note, this whole competition has been a long journey that has felt like ages. I'm 16, and really turned myself around at the start of quarantine to begin learning machine learning. I discovered Kaggle only 3 months ago, and was super surprised by the community; the community is so generous with sharing knowledge and code. I feel so proud of getting my first medal in my first competition. I hope this write-up can be inspiring as notebooks from the likes of Chris Deotte and Alex Shonenkov. Thanks to everyone!",
      "votes": null
    },
    {
      "id": "980924",
      "postDate": "08/22/2020 02:42:38",
      "content": "<p>That's impressive at only 16!  I usually don't like to use other code if I don't understand it fully as medals means nothing if you can't re-write the code without looking or explain it.</p>",
      "rawMarkdown": "That's impressive at only 16!  I usually don't like to use other code if I don't understand it fully as medals means nothing if you can't re-write the code without looking or explain it.",
      "votes": null
    },
    {
      "id": "980932",
      "postDate": "08/22/2020 03:01:25",
      "content": "<p>Thanks for the kind words! That's definitely a good point; I am not proficient enough to write my own pseudolabelling, OOF, etc. notebook from scratch (I'm currently working on ensemble from scratch in late submissions). It's definitely something for me to work towards, alongside building an intuition for hparam tuning, perhaps I will try to join the next competition earlier to not be influenced too much by the ideas of others.</p>",
      "rawMarkdown": "Thanks for the kind words! That's definitely a good point; I am not proficient enough to write my own pseudolabelling, OOF, etc. notebook from scratch (I'm currently working on ensemble from scratch in late submissions). It's definitely something for me to work towards, alongside building an intuition for hparam tuning, perhaps I will try to join the next competition earlier to not be influenced too much by the ideas of others.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 980924,
      "author_name": "srikanthpotukuchi",
      "author_url": "",
      "post_date": "08/22/2020 02:42:38",
      "content": "<p>That's impressive at only 16!  I usually don't like to use other code if I don't understand it fully as medals means nothing if you can't re-write the code without looking or explain it.</p>",
      "votes": null,
      "replies": [
        {
          "id": 980932,
          "author_name": "stanleyjzheng",
          "author_url": "",
          "post_date": "08/22/2020 03:01:25",
          "content": "<p>Thanks for the kind words! That's definitely a good point; I am not proficient enough to write my own pseudolabelling, OOF, etc. notebook from scratch (I'm currently working on ensemble from scratch in late submissions). It's definitely something for me to work towards, alongside building an intuition for hparam tuning, perhaps I will try to join the next competition earlier to not be influenced too much by the ideas of others.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "977985": "## Introduction and thanks\nMy team used both Effdet and YOLOv4 (though our final submissions were both Effdet). I focused on YOLOv4 so I will do a bit of a write up from my side. I started the competition about 2 weeks before the end after beginning learning machine learning in March. \n\nThanks to my team for supporting me throughout this competition even though I was underqualified and helping me debug. Thanks to Hawkey and NVNN for their YOLOv5 Pseudolabelling/OOF evaluation notebook, pabloberhauser for his notebook converting label formats to yolov4, and Mark Peng for precompiling Darknet binaries to work on the Kaggle enviornment. \n\n## Training\nI used AlexeyAB's [Darknet](https://github.com/AlexeyAB/darknet) to train. Using Colab Pro, the maximum image size I could get with reasonable speed was 704x704, batch size of 64, 32 subdivisions, and 94 epochs (6000 batches). All other parameters were the default given by Darknet, only adjusting filter, steps, etc. in order to train with 1 label. Training on Darknet was quite simple since it handles CV and augmentations automatically. However, labels need to be converted to txt files. I used [Pabloberhauser's notebook](https://www.kaggle.com/pabloberhauser/creating-label-files-for-use-in-yolov4) to do this. This baseline alongside WBF over TTA gets a score of only about 0.7115 public and 0.6371 private. [The WBF over TTA inference notebook is here](https://www.kaggle.com/stanleyjzheng/yolov4-wbf-inference?scriptVersionId=39789314). I experimented lots with the training; I tried modifying anchors so that they were the same as yolov5, cutmix, but none of it worked as well as default on CV. \n\n## Pseudolabelling\n\nI used NVNN's YOLOv5 notebook with Hawkey's OOF evaluation. For inference, I used [PytorchYOLOv4](https://github.com/Tianxiaomo/pytorch-YOLOv4) to convert the .weights saved model generated by Darknet into a Pytorch file for inference. I had tons of issues with training pseudolabels however. PytorchYOLOv4 was not very robust, and gave me errors randomly. After a few PR and the deadline fast approaching, I tried using Darknet to train. Libcuda.so is inaccessible on Kaggle environments, so Darknet would not compile either. Many thanks for Mark Peng for precompiling Darknet for use with Kaggle. Finally, we used Darknet to train pseudolabels. \n\nThe precompiled Darknet did not have OpenCV, so we could not use mosaic. Therefore, we had to be very careful with overfitting to the pseudolabels. We used the same config as the training above, but only 800 batches (12 epochs). Then, we performed bayesian optimization and TTA over WBF for our final submissions. The best submission was 0.7406 on public LB and 0.6625 on private LB. \n\n[Here is the notebook](https://www.kaggle.com/stanleyjzheng/yolov4pl-oof?scriptVersionId=40172709)\n\n## Final Remarks\n\nThis methodology can definitely be improved. However, with how long it took to train a model (About 28 hours on a P100 on Colab Pro at 704x704 resolution) and the short timeline I had (2 weeks), I feel this is a pretty good solution. Once late submissions open up, I plan on testing other models as well as an ensemble with effdet. \n\nOn a more personal note, this whole competition has been a long journey that has felt like ages. I'm 16, and really turned myself around at the start of quarantine to begin learning machine learning. I discovered Kaggle only 3 months ago, and was super surprised by the community; the community is so generous with sharing knowledge and code. I feel so proud of getting my first medal in my first competition. I hope this write-up can be inspiring as notebooks from the likes of Chris Deotte and Alex Shonenkov. Thanks to everyone!",
    "980924": "That's impressive at only 16!  I usually don't like to use other code if I don't understand it fully as medals means nothing if you can't re-write the code without looking or explain it.",
    "980932": "Thanks for the kind words! That's definitely a good point; I am not proficient enough to write my own pseudolabelling, OOF, etc. notebook from scratch (I'm currently working on ensemble from scratch in late submissions). It's definitely something for me to work towards, alongside building an intuition for hparam tuning, perhaps I will try to join the next competition earlier to not be influenced too much by the ideas of others."
  },
  "source": "meta"
}