{
  "id": 173153,
  "title": "Darknet YOLOv4 Inference and Pseudo-label Training on Kaggle GPU Notebook",
  "url": "/competitions/global-wheat-detection/discussion/173153",
  "author_name": "Mark Peng",
  "post_date": "2020-08-08T05:21:03.451000",
  "votes": 5,
  "comment_count": 0,
  "views": 0,
  "content": "<p>Extending the <a href=\"https://www.kaggle.com/c/global-wheat-detection/discussion/171528\" target=\"_blank\">topic</a> I shared about running darknet with GPU notebook, here is the final submission of mine using a single YOLOv4 + pseudo-labeling.<br>\n<a href=\"https://www.kaggle.com/markpeng/yolov4-infer-gpu-v3-tta-fold2-pseudo-label-final/\" target=\"_blank\">https://www.kaggle.com/markpeng/yolov4-infer-gpu-v3-tta-fold2-pseudo-label-final/</a></p>\n<p>Although the score is not that promising in current private LB compared with other great solutions integrating EfficientDet, it could still be valuable for the others in future CV competitions.</p>\n<p>Notably, one of the contributions of this notebook is the demonstration of <code>free_network_ptr</code> function defined in Darknet C library for freeing CUDA memory in Python environment, which is especially useful while ensembling bboxes from multiple YOLOv4 models in a single run. A <a href=\"https://github.com/AlexeyAB/darknet/pull/6440\" target=\"_blank\">PR</a> is also submitted to extend the same back to the Darknet community.</p>\n<p><strong>Summary about the notebook:</strong></p>\n<ul>\n<li>AlexeyAB/darknet YOLOv4 with pretrained mish-416 weights</li>\n<li>Single fold selected from stratified k-folds (K=5)</li>\n<li>Using 608x608 resolution for width and height in training config, but 1024x1024 as input</li>\n<li>About 12,000 iterations to get best weights</li>\n<li>lr=0.0005</li>\n<li>Data augmentation: mosaic=1, blur=1, gaussian_noise=1</li>\n<li>TTA + WBF</li>\n<li>In-memory inference</li>\n<li>Free CUDA memory through <code>darknet.free_network_ptr(net)</code></li>\n<li>Pseudo Labeling for 1,000 iterations, boosted ~0.0132 (~0.0097 in private LB)</li>\n<li>Public LB: 0.7352</li>\n<li>Private LB: 0.6608</li>\n</ul>\n<p>Cheers,<br>\nMark</p>",
  "messages": [
    {
      "id": 962386,
      "postDate": "2020-08-08T05:21:03.450Z",
      "content": "<p>Extending the <a href=\"https://www.kaggle.com/c/global-wheat-detection/discussion/171528\" target=\"_blank\">topic</a> I shared about running darknet with GPU notebook, here is the final submission of mine using a single YOLOv4 + pseudo-labeling.<br>\n<a href=\"https://www.kaggle.com/markpeng/yolov4-infer-gpu-v3-tta-fold2-pseudo-label-final/\" target=\"_blank\">https://www.kaggle.com/markpeng/yolov4-infer-gpu-v3-tta-fold2-pseudo-label-final/</a></p>\n<p>Although the score is not that promising in current private LB compared with other great solutions integrating EfficientDet, it could still be valuable for the others in future CV competitions.</p>\n<p>Notably, one of the contributions of this notebook is the demonstration of <code>free_network_ptr</code> function defined in Darknet C library for freeing CUDA memory in Python environment, which is especially useful while ensembling bboxes from multiple YOLOv4 models in a single run. A <a href=\"https://github.com/AlexeyAB/darknet/pull/6440\" target=\"_blank\">PR</a> is also submitted to extend the same back to the Darknet community.</p>\n<p><strong>Summary about the notebook:</strong></p>\n<ul>\n<li>AlexeyAB/darknet YOLOv4 with pretrained mish-416 weights</li>\n<li>Single fold selected from stratified k-folds (K=5)</li>\n<li>Using 608x608 resolution for width and height in training config, but 1024x1024 as input</li>\n<li>About 12,000 iterations to get best weights</li>\n<li>lr=0.0005</li>\n<li>Data augmentation: mosaic=1, blur=1, gaussian_noise=1</li>\n<li>TTA + WBF</li>\n<li>In-memory inference</li>\n<li>Free CUDA memory through <code>darknet.free_network_ptr(net)</code></li>\n<li>Pseudo Labeling for 1,000 iterations, boosted ~0.0132 (~0.0097 in private LB)</li>\n<li>Public LB: 0.7352</li>\n<li>Private LB: 0.6608</li>\n</ul>\n<p>Cheers,<br>\nMark</p>",
      "rawMarkdown": "Extending the [topic](https://www.kaggle.com/c/global-wheat-detection/discussion/171528) I shared about running darknet with GPU notebook, here is the final submission of mine using a single YOLOv4 + pseudo-labeling.\nhttps://www.kaggle.com/markpeng/yolov4-infer-gpu-v3-tta-fold2-pseudo-label-final/\n\nAlthough the score is not that promising in current private LB compared with other great solutions integrating EfficientDet, it could still be valuable for the others in future CV competitions.\n\nNotably, one of the contributions of this notebook is the demonstration of `free_network_ptr` function defined in Darknet C library for freeing CUDA memory in Python environment, which is especially useful while ensembling bboxes from multiple YOLOv4 models in a single run. A [PR](https://github.com/AlexeyAB/darknet/pull/6440) is also submitted to extend the same back to the Darknet community.\n\n**Summary about the notebook:**\n- AlexeyAB/darknet YOLOv4 with pretrained mish-416 weights\n- Single fold selected from stratified k-folds (K=5)\n- Using 608x608 resolution for width and height in training config, but 1024x1024 as input\n- About 12,000 iterations to get best weights\n- lr=0.0005\n- Data augmentation: mosaic=1, blur=1, gaussian_noise=1\n- TTA + WBF\n- In-memory inference\n- Free CUDA memory through `darknet.free_network_ptr(net)`\n- Pseudo Labeling for 1,000 iterations, boosted ~0.0132 (~0.0097 in private LB)\n- Public LB: 0.7352\n- Private LB: 0.6608\n\nCheers,\nMark",
      "votes": 5
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "962386": "Extending the [topic](https://www.kaggle.com/c/global-wheat-detection/discussion/171528) I shared about running darknet with GPU notebook, here is the final submission of mine using a single YOLOv4 + pseudo-labeling.\nhttps://www.kaggle.com/markpeng/yolov4-infer-gpu-v3-tta-fold2-pseudo-label-final/\n\nAlthough the score is not that promising in current private LB compared with other great solutions integrating EfficientDet, it could still be valuable for the others in future CV competitions.\n\nNotably, one of the contributions of this notebook is the demonstration of `free_network_ptr` function defined in Darknet C library for freeing CUDA memory in Python environment, which is especially useful while ensembling bboxes from multiple YOLOv4 models in a single run. A [PR](https://github.com/AlexeyAB/darknet/pull/6440) is also submitted to extend the same back to the Darknet community.\n\n**Summary about the notebook:**\n- AlexeyAB/darknet YOLOv4 with pretrained mish-416 weights\n- Single fold selected from stratified k-folds (K=5)\n- Using 608x608 resolution for width and height in training config, but 1024x1024 as input\n- About 12,000 iterations to get best weights\n- lr=0.0005\n- Data augmentation: mosaic=1, blur=1, gaussian_noise=1\n- TTA + WBF\n- In-memory inference\n- Free CUDA memory through `darknet.free_network_ptr(net)`\n- Pseudo Labeling for 1,000 iterations, boosted ~0.0132 (~0.0097 in private LB)\n- Public LB: 0.7352\n- Private LB: 0.6608\n\nCheers,\nMark"
  }
}