{
  "id": 199980,
  "title": "applied Augmentations with/without Normalize ",
  "url": "/competitions/cassava-leaf-disease-classification/discussion/199980",
  "author_name": "",
  "post_date": "2020-11-28T07:46:58.909353900Z",
  "votes": 3,
  "comment_count": 8,
  "views": 0,
  "content": "<p>As I was working with my augmentation part, I noticed that using Normalize(mean=[0.485, 0.456, 0.406],std=[0.229, 0.224, 0.225], ) in my augmentation function  we get the image like in the right.<br>\nBut if we don't use the normalisation but just divide the image by 255  in my dataloader class before applying transformation that is,<br>\n<code>image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB).astype(np.float32)</code><br>\n<code>image = image/255.0</code> and continue to do other augmentation except normalise,<br>\nWe get the image as in the left.</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2728242%2Fdc95e0410e87ded2847283cc6dea827e%2FUntitled.png?generation=1606548869360249&amp;alt=media\" alt=\"\"></p>\n<p>As we clearly see the left image is clearer and I think it makes the cnn see the important parts whereas using the normalise the images in the right got darker and maybe an important part in the picture gets blocked.<br>\nSo what do you think should we apply.<br>\n(I am using Albumentations)</p>",
  "messages": [
    {
      "id": "1093980",
      "postDate": "11/28/2020 07:46:58",
      "content": "<p>As I was working with my augmentation part, I noticed that using Normalize(mean=[0.485, 0.456, 0.406],std=[0.229, 0.224, 0.225], ) in my augmentation function  we get the image like in the right.<br>\nBut if we don't use the normalisation but just divide the image by 255  in my dataloader class before applying transformation that is,<br>\n<code>image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB).astype(np.float32)</code><br>\n<code>image = image/255.0</code> and continue to do other augmentation except normalise,<br>\nWe get the image as in the left.</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2728242%2Fdc95e0410e87ded2847283cc6dea827e%2FUntitled.png?generation=1606548869360249&amp;alt=media\" alt=\"\"></p>\n<p>As we clearly see the left image is clearer and I think it makes the cnn see the important parts whereas using the normalise the images in the right got darker and maybe an important part in the picture gets blocked.<br>\nSo what do you think should we apply.<br>\n(I am using Albumentations)</p>",
      "rawMarkdown": "As I was working with my augmentation part, I noticed that using Normalize(mean=[0.485, 0.456, 0.406],std=[0.229, 0.224, 0.225], ) in my augmentation function  we get the image like in the right.\nBut if we don't use the normalisation but just divide the image by 255  in my dataloader class before applying transformation that is,\n`image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB).astype(np.float32)`\n`image = image/255.0` and continue to do other augmentation except normalise,\nWe get the image as in the left.\n\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2728242%2Fdc95e0410e87ded2847283cc6dea827e%2FUntitled.png?generation=1606548869360249&alt=media)\n\nAs we clearly see the left image is clearer and I think it makes the cnn see the important parts whereas using the normalise the images in the right got darker and maybe an important part in the picture gets blocked.\nSo what do you think should we apply.\n(I am using Albumentations)",
      "votes": null
    },
    {
      "id": "1094010",
      "postDate": "11/28/2020 08:29:03",
      "content": "<p>I think the parameters from ImageNet(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) are not applicable here. <br>\nI recalculated on this competition's images: mean=[0.4580, 0.5274, 0.3245], std=[0.2267, 0.2285, 0.2170]</p>",
      "rawMarkdown": "I think the parameters from ImageNet(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) are not applicable here. \nI recalculated on this competition's images: mean=[0.4580, 0.5274, 0.3245], std=[0.2267, 0.2285, 0.2170]",
      "votes": null
    },
    {
      "id": "1094434",
      "postDate": "11/28/2020 16:03:21",
      "content": "<p>I used it but the cv didn't improved : (<br>\nI am not getting why</p>",
      "rawMarkdown": "I used it but the cv didn't improved : (\nI am not getting why",
      "votes": null
    },
    {
      "id": "1094538",
      "postDate": "11/28/2020 17:43:58",
      "content": "<p>I think you should keep your image a uint8 because albumentattions.Normalize() already divides the image by 255 and puts it between 0-1. Also it is normal that after the normlization the image colors do not look like the original image.</p>",
      "rawMarkdown": "I think you should keep your image a uint8 because albumentattions.Normalize() already divides the image by 255 and puts it between 0-1. Also it is normal that after the normlization the image colors do not look like the original image.",
      "votes": null
    },
    {
      "id": "1094603",
      "postDate": "11/28/2020 18:56:00",
      "content": "<p>When i divide by 255 i don't use normalize function, <br>\n<code>it is normal that after the normalization the image colours do not look like the original image</code> <br>\nalthough I agree with you but because of it will the model miss some important features? like the yellow colour is really important in detecting if it is healthy or not</p>",
      "rawMarkdown": "When i divide by 255 i don't use normalize function, \n`it is normal that after the normalization the image colours do not look like the original image` \nalthough I agree with you but because of it will the model miss some important features? like the yellow colour is really important in detecting if it is healthy or not",
      "votes": null
    },
    {
      "id": "1094629",
      "postDate": "11/28/2020 19:16:13",
      "content": "<p>It will no longer recognize yellow but recognize the normalized color of yellow so in the end it doesnt change anything, it just has to be consistent on the overall dataset</p>",
      "rawMarkdown": "It will no longer recognize yellow but recognize the normalized color of yellow so in the end it doesnt change anything, it just has to be consistent on the overall dataset",
      "votes": null
    },
    {
      "id": "1094946",
      "postDate": "11/29/2020 05:42:19",
      "content": "<p>Thank you for clearing my doubt</p>",
      "rawMarkdown": "Thank you for clearing my doubt",
      "votes": null
    },
    {
      "id": "1152677",
      "postDate": "01/14/2021 11:05:30",
      "content": "<p>Hi, <a href=\"https://www.kaggle.com/zzy990106\" target=\"_blank\">@zzy990106</a>! Could you please share on how you calculated mean and std? I am trying to do the same but get completely different numbers which lead to bad score:(</p>",
      "rawMarkdown": "Hi, @zzy990106! Could you please share on how you calculated mean and std? I am trying to do the same but get completely different numbers which lead to bad score:(",
      "votes": null
    },
    {
      "id": "1153674",
      "postDate": "01/15/2021 04:40:26",
      "content": "<p><a href=\"https://stackoverflow.com/questions/60101240/finding-mean-and-standard-deviation-across-image-channels-pytorch\" target=\"_blank\">https://stackoverflow.com/questions/60101240/finding-mean-and-standard-deviation-across-image-channels-pytorch</a> <a href=\"https://www.kaggle.com/etagiev\" target=\"_blank\">@etagiev</a> </p>",
      "rawMarkdown": "https://stackoverflow.com/questions/60101240/finding-mean-and-standard-deviation-across-image-channels-pytorch @etagiev",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1094010,
      "author_name": "zzy990106",
      "author_url": "",
      "post_date": "11/28/2020 08:29:03",
      "content": "<p>I think the parameters from ImageNet(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) are not applicable here. <br>\nI recalculated on this competition's images: mean=[0.4580, 0.5274, 0.3245], std=[0.2267, 0.2285, 0.2170]</p>",
      "votes": null,
      "replies": [
        {
          "id": 1094434,
          "author_name": "mrinath",
          "author_url": "",
          "post_date": "11/28/2020 16:03:21",
          "content": "<p>I used it but the cv didn't improved : (<br>\nI am not getting why</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1152677,
          "author_name": "etagiev",
          "author_url": "",
          "post_date": "01/14/2021 11:05:30",
          "content": "<p>Hi, <a href=\"https://www.kaggle.com/zzy990106\" target=\"_blank\">@zzy990106</a>! Could you please share on how you calculated mean and std? I am trying to do the same but get completely different numbers which lead to bad score:(</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1153674,
          "author_name": "mrinath",
          "author_url": "",
          "post_date": "01/15/2021 04:40:26",
          "content": "<p><a href=\"https://stackoverflow.com/questions/60101240/finding-mean-and-standard-deviation-across-image-channels-pytorch\" target=\"_blank\">https://stackoverflow.com/questions/60101240/finding-mean-and-standard-deviation-across-image-channels-pytorch</a> <a href=\"https://www.kaggle.com/etagiev\" target=\"_blank\">@etagiev</a> </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1094538,
      "author_name": "yannmajewski",
      "author_url": "",
      "post_date": "11/28/2020 17:43:58",
      "content": "<p>I think you should keep your image a uint8 because albumentattions.Normalize() already divides the image by 255 and puts it between 0-1. Also it is normal that after the normlization the image colors do not look like the original image.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1094603,
          "author_name": "mrinath",
          "author_url": "",
          "post_date": "11/28/2020 18:56:00",
          "content": "<p>When i divide by 255 i don't use normalize function, <br>\n<code>it is normal that after the normalization the image colours do not look like the original image</code> <br>\nalthough I agree with you but because of it will the model miss some important features? like the yellow colour is really important in detecting if it is healthy or not</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1094629,
          "author_name": "yannmajewski",
          "author_url": "",
          "post_date": "11/28/2020 19:16:13",
          "content": "<p>It will no longer recognize yellow but recognize the normalized color of yellow so in the end it doesnt change anything, it just has to be consistent on the overall dataset</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1094946,
          "author_name": "mrinath",
          "author_url": "",
          "post_date": "11/29/2020 05:42:19",
          "content": "<p>Thank you for clearing my doubt</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1093980": "As I was working with my augmentation part, I noticed that using Normalize(mean=[0.485, 0.456, 0.406],std=[0.229, 0.224, 0.225], ) in my augmentation function  we get the image like in the right.\nBut if we don't use the normalisation but just divide the image by 255  in my dataloader class before applying transformation that is,\n`image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB).astype(np.float32)`\n`image = image/255.0` and continue to do other augmentation except normalise,\nWe get the image as in the left.\n\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2728242%2Fdc95e0410e87ded2847283cc6dea827e%2FUntitled.png?generation=1606548869360249&alt=media)\n\nAs we clearly see the left image is clearer and I think it makes the cnn see the important parts whereas using the normalise the images in the right got darker and maybe an important part in the picture gets blocked.\nSo what do you think should we apply.\n(I am using Albumentations)",
    "1094010": "I think the parameters from ImageNet(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) are not applicable here. \nI recalculated on this competition's images: mean=[0.4580, 0.5274, 0.3245], std=[0.2267, 0.2285, 0.2170]",
    "1094434": "I used it but the cv didn't improved : (\nI am not getting why",
    "1094538": "I think you should keep your image a uint8 because albumentattions.Normalize() already divides the image by 255 and puts it between 0-1. Also it is normal that after the normlization the image colors do not look like the original image.",
    "1094603": "When i divide by 255 i don't use normalize function, \n`it is normal that after the normalization the image colours do not look like the original image` \nalthough I agree with you but because of it will the model miss some important features? like the yellow colour is really important in detecting if it is healthy or not",
    "1094629": "It will no longer recognize yellow but recognize the normalized color of yellow so in the end it doesnt change anything, it just has to be consistent on the overall dataset",
    "1094946": "Thank you for clearing my doubt",
    "1152677": "Hi, @zzy990106! Could you please share on how you calculated mean and std? I am trying to do the same but get completely different numbers which lead to bad score:(",
    "1153674": "https://stackoverflow.com/questions/60101240/finding-mean-and-standard-deviation-across-image-channels-pytorch @etagiev"
  },
  "source": "meta"
}