{
  "id": 99360,
  "title": "Cropped images improvement?",
  "url": "/competitions/generative-dog-images/discussion/99360",
  "author_name": "",
  "post_date": "2019-07-10T17:25:34.914408800Z",
  "votes": 2,
  "comment_count": 12,
  "views": 0,
  "content": "<p>My score is going up by around 12 points when I crop the images? Have you noticed that too?\nDoes anyone has been able to improve his score by using cropped images?\nThank you. </p>\n\n<p>Edit: I mean cropped using the bounding box information.</p>",
  "messages": [
    {
      "id": "572252",
      "postDate": "07/10/2019 17:25:34",
      "content": "<p>My score is going up by around 12 points when I crop the images? Have you noticed that too?\nDoes anyone has been able to improve his score by using cropped images?\nThank you. </p>\n\n<p>Edit: I mean cropped using the bounding box information.</p>",
      "rawMarkdown": "My score is going up by around 12 points when I crop the images? Have you noticed that too?\nDoes anyone has been able to improve his score by using cropped images?\nThank you. \n\nEdit: I mean cropped using the bounding box information.",
      "votes": null
    },
    {
      "id": "572254",
      "postDate": "07/10/2019 17:30:32",
      "content": "<p>I saw some improvement , but not as much as you . I am now in a double mind . My latest training I am trying without cropped images , will see how good or bad it is .. </p>",
      "rawMarkdown": "I saw some improvement , but not as much as you . I am now in a double mind . My latest training I am trying without cropped images , will see how good or bad it is ..",
      "votes": null
    },
    {
      "id": "572255",
      "postDate": "07/10/2019 17:32:22",
      "content": "<p>What I meant by going up is that it gets worse with cropped images. I must miss something then. \nThank you</p>",
      "rawMarkdown": "What I meant by going up is that it gets worse with cropped images. I must miss something then. \nThank you",
      "votes": null
    },
    {
      "id": "572273",
      "postDate": "07/10/2019 17:55:28",
      "content": "<p>I was trying multiple combination and its too difficult to track all the parameters , thats why I noted and posted . with cropped images I have score as good as 99 and as bad as 115 . Whereas with uncropped images I have score as 112 . So , trying now to run two kernels with same parameters with cropped and uncropped to understand if it really makes a lot of difference .</p>",
      "rawMarkdown": "I was trying multiple combination and its too difficult to track all the parameters , thats why I noted and posted . with cropped images I have score as good as 99 and as bad as 115 . Whereas with uncropped images I have score as 112 . So , trying now to run two kernels with same parameters with cropped and uncropped to understand if it really makes a lot of difference .",
      "votes": null
    },
    {
      "id": "572282",
      "postDate": "07/10/2019 18:09:24",
      "content": "<p>How do you use *<em>un</em>*cropped images? The original images are rectangles with <code>width != height</code>. Do you just resize them into 64x64? If so, doesn't that distort the shapes of the dogs and confuse the GAN? At the very least, I cut the biggest square I can out of the middle and then resize that to 64x64. Or I cut the biggest square out of the provided bounding box information. Alternatively I find other interesting squares within the rectangle image to use.</p>",
      "rawMarkdown": "How do you use **un**cropped images? The original images are rectangles with `width != height`. Do you just resize them into 64x64? If so, doesn't that distort the shapes of the dogs and confuse the GAN? At the very least, I cut the biggest square I can out of the middle and then resize that to 64x64. Or I cut the biggest square out of the provided bounding box information. Alternatively I find other interesting squares within the rectangle image to use.",
      "votes": null
    },
    {
      "id": "572287",
      "postDate": "07/10/2019 18:12:33",
      "content": "<p>I wanted to say cropped using the bounding box information.</p>",
      "rawMarkdown": "I wanted to say cropped using the bounding box information.",
      "votes": null
    },
    {
      "id": "572292",
      "postDate": "07/10/2019 18:27:08",
      "content": "<p>I haven't noticed any downsides when I switched to cropped versions.</p>",
      "rawMarkdown": "I haven't noticed any downsides when I switched to cropped versions.",
      "votes": null
    },
    {
      "id": "572424",
      "postDate": "07/10/2019 23:30:06",
      "content": "<p>I think Chris means the bounding box should satisfy width == height, and I just read your public kernel and found you didn't do the denormalization, please save images with something like generated_images*0.5+0.5 which depends on your normalization.</p>",
      "rawMarkdown": "I think Chris means the bounding box should satisfy width == height, and I just read your public kernel and found you didn't do the denormalization, please save images with something like generated_images*0.5+0.5 which depends on your normalization.",
      "votes": null
    },
    {
      "id": "572819",
      "postDate": "07/11/2019 12:39:29",
      "content": "<p><a href=\"/cdeotte\">@cdeotte</a> here is my approach to cropping: I crop each dog using bboxes from annotations, resize it preventing sides ratio so that the shortest side is 64, normalize images by lambda x: x / 127.5 - 1, and store them in some array,  when constructing batch for my network I select some N=batch-size images from that array and transform each as follow: image = random-horizontal-flip(random-crop(image, h=64, w=64), flip-probability=0.5)</p>",
      "rawMarkdown": "cdeotte here is my approach to cropping: I crop each dog using bboxes from annotations, resize it preventing sides ratio so that the shortest side is 64, normalize images by lambda x: x / 127.5 - 1, and store them in some array,  when constructing batch for my network I select some N=batch-size images from that array and transform each as follow: image = random-horizontal-flip(random-crop(image, h=64, w=64), flip-probability=0.5)",
      "votes": null
    },
    {
      "id": "572826",
      "postDate": "07/11/2019 12:49:02",
      "content": "<p><a href=\"/cdeotte\">@cdeotte</a> I doubt distorted shapes will confuse GAN, it will just generate distorted dogs, and as <a href=\"https://www.kaggle.com/wendykan/demo-mifid-metric-for-dog-image-generation-comp\">MiFID calculation kernel</a> uses just resized images without cropping by bboxes to compute latent space distribution for real dogs, maybe doing so will improve MiFID metric.</p>",
      "rawMarkdown": "cdeotte I doubt distorted shapes will confuse GAN, it will just generate distorted dogs, and as [MiFID calculation kernel](https://www.kaggle.com/wendykan/demo-mifid-metric-for-dog-image-generation-comp) uses just resized images without cropping by bboxes to compute latent space distribution for real dogs, maybe doing so will improve MiFID metric.",
      "votes": null
    },
    {
      "id": "572852",
      "postDate": "07/11/2019 13:36:56",
      "content": "<p>&gt; and as MiFID calculation kernel uses just resized images without cropping by bboxes to compute latent space distribution for real dogs, maybe doing so will improve MiFID metric.</p>\n\n<p>Wow, you are correct. I missed that. FID calculates the similarity between two sets of images. We are comparing our generated images to distorted ImageNet images (rectangles resized to squares). Therefore to maximize FID, we want distorted images too.</p>\n\n<p>(However, the feature space of Inception layer may be invariant to resize distortion, in which case either way would produce the same FID).</p>",
      "rawMarkdown": "&gt; and as MiFID calculation kernel uses just resized images without cropping by bboxes to compute latent space distribution for real dogs, maybe doing so will improve MiFID metric.\n\nWow, you are correct. I missed that. FID calculates the similarity between two sets of images. We are comparing our generated images to distorted ImageNet images (rectangles resized to squares). Therefore to maximize FID, we want distorted images too.\n\n(However, the feature space of Inception layer may be invariant to resize distortion, in which case either way would produce the same FID).",
      "votes": null
    },
    {
      "id": "572862",
      "postDate": "07/11/2019 13:45:07",
      "content": "<blockquote>\n  <p>here is my approach to cropping: I crop each dog using bboxes from annotations, resize it preventing sides ratio so that the shortest side is 64, normalize images by lambda x: x / 127.5 - 1, and store them in some array, when constructing batch for my network I select some N=batch-size images from that array and transform each as follow: image = random-horizontal-flip(random-crop(image, h=64, w=64), flip-probability=0.5)</p>\n</blockquote>\n\n<p>That's a great pipeline. Thanks for sharing. The pictures that I've posted only use random horizontal flipping (and pixel normalize to [-1,1]). I always been using the biggest centered square inside bounding box. Recently I've added random zoom ins. I pick a random located square of side 50 thru 64 within my original 64x64 crop. Then I resize the random square to 64x64.</p>\n\n<p>I'm gonna try your idea of choosing an original random 64x64. That's a good idea.</p>",
      "rawMarkdown": "&gt; here is my approach to cropping: I crop each dog using bboxes from annotations, resize it preventing sides ratio so that the shortest side is 64, normalize images by lambda x: x / 127.5 - 1, and store them in some array, when constructing batch for my network I select some N=batch-size images from that array and transform each as follow: image = random-horizontal-flip(random-crop(image, h=64, w=64), flip-probability=0.5)\n\nThat's a great pipeline. Thanks for sharing. The pictures that I've posted only use random horizontal flipping (and pixel normalize to [-1,1]). I always been using the biggest centered square inside bounding box. Recently I've added random zoom ins. I pick a random located square of side 50 thru 64 within my original 64x64 crop. Then I resize the random square to 64x64.\n\nI'm gonna try your idea of choosing an original random 64x64. That's a good idea.",
      "votes": null
    },
    {
      "id": "572864",
      "postDate": "07/11/2019 13:49:44",
      "content": "<p>Just yesterday I started making CGANs. And I've realized that CGANs need data augmentation. Otherwise we only have approx 200 images of each breed and many classes collapses to a single bad generated image. </p>",
      "rawMarkdown": "Just yesterday I started making CGANs. And I've realized that CGANs need data augmentation. Otherwise we only have approx 200 images of each breed and many classes collapses to a single bad generated image.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 572254,
      "author_name": "phoenix9032",
      "author_url": "",
      "post_date": "07/10/2019 17:30:32",
      "content": "<p>I saw some improvement , but not as much as you . I am now in a double mind . My latest training I am trying without cropped images , will see how good or bad it is .. </p>",
      "votes": null,
      "replies": [
        {
          "id": 572255,
          "author_name": "francoisdubois",
          "author_url": "",
          "post_date": "07/10/2019 17:32:22",
          "content": "<p>What I meant by going up is that it gets worse with cropped images. I must miss something then. \nThank you</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 572273,
          "author_name": "phoenix9032",
          "author_url": "",
          "post_date": "07/10/2019 17:55:28",
          "content": "<p>I was trying multiple combination and its too difficult to track all the parameters , thats why I noted and posted . with cropped images I have score as good as 99 and as bad as 115 . Whereas with uncropped images I have score as 112 . So , trying now to run two kernels with same parameters with cropped and uncropped to understand if it really makes a lot of difference .</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 572282,
      "author_name": "cdeotte",
      "author_url": "",
      "post_date": "07/10/2019 18:09:24",
      "content": "<p>How do you use *<em>un</em>*cropped images? The original images are rectangles with <code>width != height</code>. Do you just resize them into 64x64? If so, doesn't that distort the shapes of the dogs and confuse the GAN? At the very least, I cut the biggest square I can out of the middle and then resize that to 64x64. Or I cut the biggest square out of the provided bounding box information. Alternatively I find other interesting squares within the rectangle image to use.</p>",
      "votes": null,
      "replies": [
        {
          "id": 572287,
          "author_name": "francoisdubois",
          "author_url": "",
          "post_date": "07/10/2019 18:12:33",
          "content": "<p>I wanted to say cropped using the bounding box information.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 572424,
          "author_name": "jionie",
          "author_url": "",
          "post_date": "07/10/2019 23:30:06",
          "content": "<p>I think Chris means the bounding box should satisfy width == height, and I just read your public kernel and found you didn't do the denormalization, please save images with something like generated_images*0.5+0.5 which depends on your normalization.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 572819,
          "author_name": "kostyaatarik",
          "author_url": "",
          "post_date": "07/11/2019 12:39:29",
          "content": "<p><a href=\"/cdeotte\">@cdeotte</a> here is my approach to cropping: I crop each dog using bboxes from annotations, resize it preventing sides ratio so that the shortest side is 64, normalize images by lambda x: x / 127.5 - 1, and store them in some array,  when constructing batch for my network I select some N=batch-size images from that array and transform each as follow: image = random-horizontal-flip(random-crop(image, h=64, w=64), flip-probability=0.5)</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 572826,
          "author_name": "kostyaatarik",
          "author_url": "",
          "post_date": "07/11/2019 12:49:02",
          "content": "<p><a href=\"/cdeotte\">@cdeotte</a> I doubt distorted shapes will confuse GAN, it will just generate distorted dogs, and as <a href=\"https://www.kaggle.com/wendykan/demo-mifid-metric-for-dog-image-generation-comp\">MiFID calculation kernel</a> uses just resized images without cropping by bboxes to compute latent space distribution for real dogs, maybe doing so will improve MiFID metric.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 572852,
          "author_name": "cdeotte",
          "author_url": "",
          "post_date": "07/11/2019 13:36:56",
          "content": "<p>&gt; and as MiFID calculation kernel uses just resized images without cropping by bboxes to compute latent space distribution for real dogs, maybe doing so will improve MiFID metric.</p>\n\n<p>Wow, you are correct. I missed that. FID calculates the similarity between two sets of images. We are comparing our generated images to distorted ImageNet images (rectangles resized to squares). Therefore to maximize FID, we want distorted images too.</p>\n\n<p>(However, the feature space of Inception layer may be invariant to resize distortion, in which case either way would produce the same FID).</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 572862,
          "author_name": "cdeotte",
          "author_url": "",
          "post_date": "07/11/2019 13:45:07",
          "content": "<blockquote>\n  <p>here is my approach to cropping: I crop each dog using bboxes from annotations, resize it preventing sides ratio so that the shortest side is 64, normalize images by lambda x: x / 127.5 - 1, and store them in some array, when constructing batch for my network I select some N=batch-size images from that array and transform each as follow: image = random-horizontal-flip(random-crop(image, h=64, w=64), flip-probability=0.5)</p>\n</blockquote>\n\n<p>That's a great pipeline. Thanks for sharing. The pictures that I've posted only use random horizontal flipping (and pixel normalize to [-1,1]). I always been using the biggest centered square inside bounding box. Recently I've added random zoom ins. I pick a random located square of side 50 thru 64 within my original 64x64 crop. Then I resize the random square to 64x64.</p>\n\n<p>I'm gonna try your idea of choosing an original random 64x64. That's a good idea.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 572864,
          "author_name": "cdeotte",
          "author_url": "",
          "post_date": "07/11/2019 13:49:44",
          "content": "<p>Just yesterday I started making CGANs. And I've realized that CGANs need data augmentation. Otherwise we only have approx 200 images of each breed and many classes collapses to a single bad generated image. </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 572292,
      "author_name": "dvorobiev",
      "author_url": "",
      "post_date": "07/10/2019 18:27:08",
      "content": "<p>I haven't noticed any downsides when I switched to cropped versions.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "572252": "My score is going up by around 12 points when I crop the images? Have you noticed that too?\nDoes anyone has been able to improve his score by using cropped images?\nThank you. \n\nEdit: I mean cropped using the bounding box information.",
    "572254": "I saw some improvement , but not as much as you . I am now in a double mind . My latest training I am trying without cropped images , will see how good or bad it is ..",
    "572255": "What I meant by going up is that it gets worse with cropped images. I must miss something then. \nThank you",
    "572273": "I was trying multiple combination and its too difficult to track all the parameters , thats why I noted and posted . with cropped images I have score as good as 99 and as bad as 115 . Whereas with uncropped images I have score as 112 . So , trying now to run two kernels with same parameters with cropped and uncropped to understand if it really makes a lot of difference .",
    "572282": "How do you use **un**cropped images? The original images are rectangles with `width != height`. Do you just resize them into 64x64? If so, doesn't that distort the shapes of the dogs and confuse the GAN? At the very least, I cut the biggest square I can out of the middle and then resize that to 64x64. Or I cut the biggest square out of the provided bounding box information. Alternatively I find other interesting squares within the rectangle image to use.",
    "572287": "I wanted to say cropped using the bounding box information.",
    "572292": "I haven't noticed any downsides when I switched to cropped versions.",
    "572424": "I think Chris means the bounding box should satisfy width == height, and I just read your public kernel and found you didn't do the denormalization, please save images with something like generated_images*0.5+0.5 which depends on your normalization.",
    "572819": "cdeotte here is my approach to cropping: I crop each dog using bboxes from annotations, resize it preventing sides ratio so that the shortest side is 64, normalize images by lambda x: x / 127.5 - 1, and store them in some array,  when constructing batch for my network I select some N=batch-size images from that array and transform each as follow: image = random-horizontal-flip(random-crop(image, h=64, w=64), flip-probability=0.5)",
    "572826": "cdeotte I doubt distorted shapes will confuse GAN, it will just generate distorted dogs, and as [MiFID calculation kernel](https://www.kaggle.com/wendykan/demo-mifid-metric-for-dog-image-generation-comp) uses just resized images without cropping by bboxes to compute latent space distribution for real dogs, maybe doing so will improve MiFID metric.",
    "572852": "&gt; and as MiFID calculation kernel uses just resized images without cropping by bboxes to compute latent space distribution for real dogs, maybe doing so will improve MiFID metric.\n\nWow, you are correct. I missed that. FID calculates the similarity between two sets of images. We are comparing our generated images to distorted ImageNet images (rectangles resized to squares). Therefore to maximize FID, we want distorted images too.\n\n(However, the feature space of Inception layer may be invariant to resize distortion, in which case either way would produce the same FID).",
    "572862": "&gt; here is my approach to cropping: I crop each dog using bboxes from annotations, resize it preventing sides ratio so that the shortest side is 64, normalize images by lambda x: x / 127.5 - 1, and store them in some array, when constructing batch for my network I select some N=batch-size images from that array and transform each as follow: image = random-horizontal-flip(random-crop(image, h=64, w=64), flip-probability=0.5)\n\nThat's a great pipeline. Thanks for sharing. The pictures that I've posted only use random horizontal flipping (and pixel normalize to [-1,1]). I always been using the biggest centered square inside bounding box. Recently I've added random zoom ins. I pick a random located square of side 50 thru 64 within my original 64x64 crop. Then I resize the random square to 64x64.\n\nI'm gonna try your idea of choosing an original random 64x64. That's a good idea.",
    "572864": "Just yesterday I started making CGANs. And I've realized that CGANs need data augmentation. Otherwise we only have approx 200 images of each breed and many classes collapses to a single bad generated image."
  },
  "source": "meta"
}