{
  "id": 296976,
  "title": "Augmentations for Object Detection",
  "url": "/competitions/tensorflow-great-barrier-reef/discussion/296976",
  "author_name": "Ravi Shah",
  "post_date": "2021-12-24T16:10:49.699000",
  "votes": 12,
  "comment_count": 12,
  "views": 0,
  "content": "<p>Augmentations on images are pretty simple: you create a slightly new variation of the original image. The challenge for object detection is that you also have to account for the bounding boxes of the images. This may not be too challenging for an augmentation on something like color, but if you are shifting the image with an augmentation such as a rotation, the bounding boxes will get messed up.</p>\n<p><strong>Albumentations Bounding Box</strong><br>\nAlbumentations is a very common python library for image augmentations. Luckily, it has a built in feature that allows it to work for object detection</p>\n<p>Example:</p>\n<pre><code>transform = A.Compose([\n    A.HorizontalFlip(p=0.5),\n], bbox_params=A.BboxParams(format='coco'))\n</code></pre>\n<p><a href=\"https://albumentations.ai/docs/getting_started/bounding_boxes_augmentation/\" target=\"_blank\">Documentation</a></p>\n<p><strong>APIs</strong><br>\nThis option is a little more specific for people who are using an API such as the TensorFlow Object Detection API or YOLOX-s. You can usually add some augmentations in the configuration files that you use for these APIs. </p>\n<p>TensorFlow OD API Example:</p>\n<pre><code>data_augmentation_options {\n    random_horizontal_flip {\n         probability: 0.5\n    }\n}\n</code></pre>\n<p>YoloX Example:</p>\n<pre><code>from yolox.exp import Exp as MyExp\nclass Exp(MyExp):\n    def __init__(self):\n        super(Exp, self).__init__()\n        self.flip_prob = 0.5\n</code></pre>\n<p><a href=\"https://www.kaggle.com/ravishah1/cots-faster-rcnn-training-w-tf-2-0-od-api-0-474\" target=\"_blank\">My TensorFlow Example</a><br>\n<a href=\"https://www.kaggle.com/remekkinas/yolox-training-pipeline-cots-dataset-lb-0-507\" target=\"_blank\">remekkinas YoloX Example</a></p>\n<p>Feel free to comment any questions or other ideas.</p>",
  "messages": [
    {
      "id": 1628210,
      "postDate": "2021-12-24T16:10:49.700Z",
      "content": "<p>Augmentations on images are pretty simple: you create a slightly new variation of the original image. The challenge for object detection is that you also have to account for the bounding boxes of the images. This may not be too challenging for an augmentation on something like color, but if you are shifting the image with an augmentation such as a rotation, the bounding boxes will get messed up.</p>\n<p><strong>Albumentations Bounding Box</strong><br>\nAlbumentations is a very common python library for image augmentations. Luckily, it has a built in feature that allows it to work for object detection</p>\n<p>Example:</p>\n<pre><code>transform = A.Compose([\n    A.HorizontalFlip(p=0.5),\n], bbox_params=A.BboxParams(format='coco'))\n</code></pre>\n<p><a href=\"https://albumentations.ai/docs/getting_started/bounding_boxes_augmentation/\" target=\"_blank\">Documentation</a></p>\n<p><strong>APIs</strong><br>\nThis option is a little more specific for people who are using an API such as the TensorFlow Object Detection API or YOLOX-s. You can usually add some augmentations in the configuration files that you use for these APIs. </p>\n<p>TensorFlow OD API Example:</p>\n<pre><code>data_augmentation_options {\n    random_horizontal_flip {\n         probability: 0.5\n    }\n}\n</code></pre>\n<p>YoloX Example:</p>\n<pre><code>from yolox.exp import Exp as MyExp\nclass Exp(MyExp):\n    def __init__(self):\n        super(Exp, self).__init__()\n        self.flip_prob = 0.5\n</code></pre>\n<p><a href=\"https://www.kaggle.com/ravishah1/cots-faster-rcnn-training-w-tf-2-0-od-api-0-474\" target=\"_blank\">My TensorFlow Example</a><br>\n<a href=\"https://www.kaggle.com/remekkinas/yolox-training-pipeline-cots-dataset-lb-0-507\" target=\"_blank\">remekkinas YoloX Example</a></p>\n<p>Feel free to comment any questions or other ideas.</p>",
      "rawMarkdown": "Augmentations on images are pretty simple: you create a slightly new variation of the original image. The challenge for object detection is that you also have to account for the bounding boxes of the images. This may not be too challenging for an augmentation on something like color, but if you are shifting the image with an augmentation such as a rotation, the bounding boxes will get messed up.\n\n**Albumentations Bounding Box**\nAlbumentations is a very common python library for image augmentations. Luckily, it has a built in feature that allows it to work for object detection\n\nExample:\n```\ntransform = A.Compose([\n    A.HorizontalFlip(p=0.5),\n], bbox_params=A.BboxParams(format='coco'))\n```\n\n[Documentation](https://albumentations.ai/docs/getting_started/bounding_boxes_augmentation/)\n\n**APIs**\nThis option is a little more specific for people who are using an API such as the TensorFlow Object Detection API or YOLOX-s. You can usually add some augmentations in the configuration files that you use for these APIs. \n\nTensorFlow OD API Example:\n```\ndata_augmentation_options {\n    random_horizontal_flip {\n         probability: 0.5\n    }\n}\n```\n\nYoloX Example:\n```\nfrom yolox.exp import Exp as MyExp\nclass Exp(MyExp):\n    def __init__(self):\n        super(Exp, self).__init__()\n        self.flip_prob = 0.5\n```\n\n[My TensorFlow Example](https://www.kaggle.com/ravishah1/cots-faster-rcnn-training-w-tf-2-0-od-api-0-474)\n[remekkinas YoloX Example](https://www.kaggle.com/remekkinas/yolox-training-pipeline-cots-dataset-lb-0-507)\n\nFeel free to comment any questions or other ideas.",
      "votes": 12
    },
    {
      "id": 1628301,
      "postDate": "2021-12-24T17:44:22.530Z",
      "content": "<p>Thank you for creating interesting topic about augumentation. YoloX does not support Albimentations from the box. I made changes to implementation (it requires some changes in core due to bbxox transformation in affine function - Albumentions does not supports such boxes). If you are interested in I can post my notebook with changes. It fully supports Albumentstions which you can setup like any other hyperparamryers in Exp class. </p>\n<p>Thank you for mentioning my work. I really appreciate. Certainly voted your post! </p>",
      "rawMarkdown": "Thank you for creating interesting topic about augumentation. YoloX does not support Albimentations from the box. I made changes to implementation (it requires some changes in core due to bbxox transformation in affine function - Albumentions does not supports such boxes). If you are interested in I can post my notebook with changes. It fully supports Albumentstions which you can setup like any other hyperparamryers in Exp class. \n\nThank you for mentioning my work. I really appreciate. Certainly voted your post! ",
      "votes": 2,
      "replies": [
        {
          "id": 1628427,
          "postDate": "2021-12-24T21:01:29.793Z",
          "content": "<p>Thank you for your reply. I am not too familiar with yolo so thank you for clearing that up.</p>",
          "rawMarkdown": "Thank you for your reply. I am not too familiar with yolo so thank you for clearing that up."
        },
        {
          "id": 1630961,
          "postDate": "2021-12-27T21:47:39.730Z",
          "content": "<p>Congrats <a href=\"https://www.kaggle.com/remekkinas\" target=\"_blank\">@remekkinas</a> on getting over 0.55x! I want to make some changes to Yolox and add the copy-paste augmentation which I saw an Albumentation implementation of, do you mind posting your notebook with the Albumentation support for YoloX? </p>",
          "rawMarkdown": "Congrats @remekkinas on getting over 0.55x! I want to make some changes to Yolox and add the copy-paste augmentation which I saw an Albumentation implementation of, do you mind posting your notebook with the Albumentation support for YoloX? ",
          "votes": 1
        },
        {
          "id": 1630965,
          "postDate": "2021-12-27T21:56:28.537Z",
          "content": "<p>Yes, end of this week. </p>",
          "rawMarkdown": "Yes, end of this week. ",
          "votes": 3
        },
        {
          "id": 1631073,
          "postDate": "2021-12-28T02:26:29.667Z",
          "content": "<p>Copy-paste augmentation need segmentation mask to work</p>",
          "rawMarkdown": "Copy-paste augmentation need segmentation mask to work",
          "votes": 2
        },
        {
          "id": 1631721,
          "postDate": "2021-12-28T18:02:55.527Z",
          "content": "<p>Ah thanks didn't know that. My YoloX is not performing so well on small detection although the mixup/mosaic implementation in YoloX is supposed to improve that. I will try YoloR today </p>",
          "rawMarkdown": "Ah thanks didn't know that. My YoloX is not performing so well on small detection although the mixup/mosaic implementation in YoloX is supposed to improve that. I will try YoloR today ",
          "votes": 1
        },
        {
          "id": 1631840,
          "postDate": "2021-12-28T20:37:45.930Z",
          "content": "<p>Augumentation pipeline in YoloR is similar to early version of Yolo5 but there is no Albumentations implemented. Im sure … YoloR not improve your score. Only way to improve it is to prepare dataset and make really good augumentation strategy. I personally think that Yolo5 is like autoML for computer vision. They have done really great job. Yolo5 is … rocket machine … if you want to do something … I am sure most of your ideas are implemented in Yolo5. But …. I am not able to jump higher then 0.55x with Yolov5 😂😳🤒😓😅😭😭</p>",
          "rawMarkdown": "Augumentation pipeline in YoloR is similar to early version of Yolo5 but there is no Albumentations implemented. Im sure ... YoloR not improve your score. Only way to improve it is to prepare dataset and make really good augumentation strategy. I personally think that Yolo5 is like autoML for computer vision. They have done really great job. Yolo5 is ... rocket machine ... if you want to do something ... I am sure most of your ideas are implemented in Yolo5. But .... I am not able to jump higher then 0.55x with Yolov5 😂😳🤒😓😅😭😭",
          "votes": 3
        },
        {
          "id": 1631898,
          "postDate": "2021-12-28T22:09:49.150Z",
          "content": "<p><a href=\"https://www.kaggle.com/wilbertbhtan\" target=\"_blank\">@wilbertbhtan</a> now you can play with YoloR :) <a href=\"https://www.kaggle.com/remekkinas/yolor-p6-w6-one-more-yolo-on-kaggle-train\" target=\"_blank\">https://www.kaggle.com/remekkinas/yolor-p6-w6-one-more-yolo-on-kaggle-train</a></p>",
          "rawMarkdown": "@wilbertbhtan now you can play with YoloR :) https://www.kaggle.com/remekkinas/yolor-p6-w6-one-more-yolo-on-kaggle-train",
          "votes": 3
        },
        {
          "id": 1632463,
          "postDate": "2021-12-29T17:11:36.567Z",
          "content": "<p>haha thanks <a href=\"https://www.kaggle.com/remekkinas\" target=\"_blank\">@remekkinas</a>, yes I agree with you Yolov5 is the autoML. As a noob I learn so much from your work. At the moment I am playing with metric.py script and trying to tune towards F2 score (recall) with Yolov5. I see YoloR allows the editing of the metric script the same as Yolov5 and the results have so many types of metric optimization. Have you tried optimizing the metrics script? </p>",
          "rawMarkdown": "haha thanks @remekkinas, yes I agree with you Yolov5 is the autoML. As a noob I learn so much from your work. At the moment I am playing with metric.py script and trying to tune towards F2 score (recall) with Yolov5. I see YoloR allows the editing of the metric script the same as Yolov5 and the results have so many types of metric optimization. Have you tried optimizing the metrics script? ",
          "votes": 1
        },
        {
          "id": 1634676,
          "postDate": "2022-01-01T02:25:35.917Z",
          "rawMarkdown": "",
          "votes": 1,
          "isDeleted": true
        },
        {
          "id": 1634865,
          "postDate": "2022-01-01T09:10:12.073Z",
          "content": "<p>Will be soon …. I am working on many topics now … it is in progress.</p>",
          "rawMarkdown": "Will be soon .... I am working on many topics now ... it is in progress.",
          "votes": 2
        }
      ]
    },
    {
      "id": 1815196,
      "postDate": "2022-06-08T19:27:10.493Z",
      "content": "<p>Thanks for creating the discussion. Can you please update about how to do RandomScale, Random Translate, Random Rotate, Random Shearing in TFOD API?<br>\nI have found these in this notebook <a href=\"https://www.kaggle.com/code/andradaolteanu/greatbarrierreef-full-guide-to-bboxaugmentation#3.-Bounding-Box-Augmentation\" target=\"_blank\">https://www.kaggle.com/code/andradaolteanu/greatbarrierreef-full-guide-to-bboxaugmentation#3.-Bounding-Box-Augmentation</a> , But I am unable to implement this in TFOD pipeline config</p>",
      "rawMarkdown": "Thanks for creating the discussion. Can you please update about how to do RandomScale, Random Translate, Random Rotate, Random Shearing in TFOD API?\nI have found these in this notebook https://www.kaggle.com/code/andradaolteanu/greatbarrierreef-full-guide-to-bboxaugmentation#3.-Bounding-Box-Augmentation , But I am unable to implement this in TFOD pipeline config"
    }
  ],
  "comments": [
    {
      "id": 1628301,
      "author_name": "Remek Kinas",
      "author_url": "",
      "post_date": "2021-12-24T17:44:22.530000",
      "content": "<p>Thank you for creating interesting topic about augumentation. YoloX does not support Albimentations from the box. I made changes to implementation (it requires some changes in core due to bbxox transformation in affine function - Albumentions does not supports such boxes). If you are interested in I can post my notebook with changes. It fully supports Albumentstions which you can setup like any other hyperparamryers in Exp class. </p>\n<p>Thank you for mentioning my work. I really appreciate. Certainly voted your post! </p>",
      "votes": 2,
      "replies": [
        {
          "id": 1628427,
          "author_name": "Ravi Shah",
          "author_url": "",
          "post_date": "2021-12-24T21:01:29.793000",
          "content": "<p>Thank you for your reply. I am not too familiar with yolo so thank you for clearing that up.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1630961,
          "author_name": "Wilbert Tan",
          "author_url": "",
          "post_date": "2021-12-27T21:47:39.730000",
          "content": "<p>Congrats <a href=\"https://www.kaggle.com/remekkinas\" target=\"_blank\">@remekkinas</a> on getting over 0.55x! I want to make some changes to Yolox and add the copy-paste augmentation which I saw an Albumentation implementation of, do you mind posting your notebook with the Albumentation support for YoloX? </p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1630965,
          "author_name": "Remek Kinas",
          "author_url": "",
          "post_date": "2021-12-27T21:56:28.537000",
          "content": "<p>Yes, end of this week. </p>",
          "votes": 3,
          "replies": []
        },
        {
          "id": 1631073,
          "author_name": "Phat Tran",
          "author_url": "",
          "post_date": "2021-12-28T02:26:29.667000",
          "content": "<p>Copy-paste augmentation need segmentation mask to work</p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 1631721,
          "author_name": "Wilbert Tan",
          "author_url": "",
          "post_date": "2021-12-28T18:02:55.527000",
          "content": "<p>Ah thanks didn't know that. My YoloX is not performing so well on small detection although the mixup/mosaic implementation in YoloX is supposed to improve that. I will try YoloR today </p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1631840,
          "author_name": "Remek Kinas",
          "author_url": "",
          "post_date": "2021-12-28T20:37:45.930000",
          "content": "<p>Augumentation pipeline in YoloR is similar to early version of Yolo5 but there is no Albumentations implemented. Im sure … YoloR not improve your score. Only way to improve it is to prepare dataset and make really good augumentation strategy. I personally think that Yolo5 is like autoML for computer vision. They have done really great job. Yolo5 is … rocket machine … if you want to do something … I am sure most of your ideas are implemented in Yolo5. But …. I am not able to jump higher then 0.55x with Yolov5 😂😳🤒😓😅😭😭</p>",
          "votes": 3,
          "replies": []
        },
        {
          "id": 1631898,
          "author_name": "Remek Kinas",
          "author_url": "",
          "post_date": "2021-12-28T22:09:49.150000",
          "content": "<p><a href=\"https://www.kaggle.com/wilbertbhtan\" target=\"_blank\">@wilbertbhtan</a> now you can play with YoloR :) <a href=\"https://www.kaggle.com/remekkinas/yolor-p6-w6-one-more-yolo-on-kaggle-train\" target=\"_blank\">https://www.kaggle.com/remekkinas/yolor-p6-w6-one-more-yolo-on-kaggle-train</a></p>",
          "votes": 3,
          "replies": []
        },
        {
          "id": 1632463,
          "author_name": "Wilbert Tan",
          "author_url": "",
          "post_date": "2021-12-29T17:11:36.567000",
          "content": "<p>haha thanks <a href=\"https://www.kaggle.com/remekkinas\" target=\"_blank\">@remekkinas</a>, yes I agree with you Yolov5 is the autoML. As a noob I learn so much from your work. At the moment I am playing with metric.py script and trying to tune towards F2 score (recall) with Yolov5. I see YoloR allows the editing of the metric script the same as Yolov5 and the results have so many types of metric optimization. Have you tried optimizing the metrics script? </p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1634676,
          "author_name": "",
          "author_url": "",
          "post_date": "2022-01-01T02:25:35.917000",
          "content": "",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1634865,
          "author_name": "Remek Kinas",
          "author_url": "",
          "post_date": "2022-01-01T09:10:12.073000",
          "content": "<p>Will be soon …. I am working on many topics now … it is in progress.</p>",
          "votes": 2,
          "replies": []
        }
      ]
    },
    {
      "id": 1815196,
      "author_name": "S.M.ABRAR MUSTAKIM TAKI",
      "author_url": "",
      "post_date": "2022-06-08T19:27:10.493000",
      "content": "<p>Thanks for creating the discussion. Can you please update about how to do RandomScale, Random Translate, Random Rotate, Random Shearing in TFOD API?<br>\nI have found these in this notebook <a href=\"https://www.kaggle.com/code/andradaolteanu/greatbarrierreef-full-guide-to-bboxaugmentation#3.-Bounding-Box-Augmentation\" target=\"_blank\">https://www.kaggle.com/code/andradaolteanu/greatbarrierreef-full-guide-to-bboxaugmentation#3.-Bounding-Box-Augmentation</a> , But I am unable to implement this in TFOD pipeline config</p>",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1628210": "Augmentations on images are pretty simple: you create a slightly new variation of the original image. The challenge for object detection is that you also have to account for the bounding boxes of the images. This may not be too challenging for an augmentation on something like color, but if you are shifting the image with an augmentation such as a rotation, the bounding boxes will get messed up.\n\n**Albumentations Bounding Box**\nAlbumentations is a very common python library for image augmentations. Luckily, it has a built in feature that allows it to work for object detection\n\nExample:\n```\ntransform = A.Compose([\n    A.HorizontalFlip(p=0.5),\n], bbox_params=A.BboxParams(format='coco'))\n```\n\n[Documentation](https://albumentations.ai/docs/getting_started/bounding_boxes_augmentation/)\n\n**APIs**\nThis option is a little more specific for people who are using an API such as the TensorFlow Object Detection API or YOLOX-s. You can usually add some augmentations in the configuration files that you use for these APIs. \n\nTensorFlow OD API Example:\n```\ndata_augmentation_options {\n    random_horizontal_flip {\n         probability: 0.5\n    }\n}\n```\n\nYoloX Example:\n```\nfrom yolox.exp import Exp as MyExp\nclass Exp(MyExp):\n    def __init__(self):\n        super(Exp, self).__init__()\n        self.flip_prob = 0.5\n```\n\n[My TensorFlow Example](https://www.kaggle.com/ravishah1/cots-faster-rcnn-training-w-tf-2-0-od-api-0-474)\n[remekkinas YoloX Example](https://www.kaggle.com/remekkinas/yolox-training-pipeline-cots-dataset-lb-0-507)\n\nFeel free to comment any questions or other ideas.",
    "1628301": "Thank you for creating interesting topic about augumentation. YoloX does not support Albimentations from the box. I made changes to implementation (it requires some changes in core due to bbxox transformation in affine function - Albumentions does not supports such boxes). If you are interested in I can post my notebook with changes. It fully supports Albumentstions which you can setup like any other hyperparamryers in Exp class. \n\nThank you for mentioning my work. I really appreciate. Certainly voted your post! ",
    "1815196": "Thanks for creating the discussion. Can you please update about how to do RandomScale, Random Translate, Random Rotate, Random Shearing in TFOD API?\nI have found these in this notebook https://www.kaggle.com/code/andradaolteanu/greatbarrierreef-full-guide-to-bboxaugmentation#3.-Bounding-Box-Augmentation , But I am unable to implement this in TFOD pipeline config"
  }
}