{
  "id": 153872,
  "title": "List of tiles or large single image made of tiles?",
  "url": "/competitions/prostate-cancer-grade-assessment/discussion/153872",
  "author_name": "Claudio Fanconi",
  "post_date": "2020-05-26T12:30:34.782000",
  "votes": 17,
  "comment_count": 29,
  "views": 0,
  "content": "<p>Hi there,\nI have another discussion topic:</p>\n\n<p>I have seen two general approaches sofar in the public notebooks:\nThe first passes a list of N images=tiles, and concatenates them before passing through the transfer learning pass.\nThe second approach creates a large image of the consisting tiles and then passes it through the whole network as one. Hence the image has the size sqrt(N) x sqrt(N).</p>\n\n<p>What are the pros and cons of both methods?\nCouldn't it be for example, that in the second method, the classifier learns something it shouldn't from the borders between the tiles in the image?</p>",
  "messages": [
    {
      "id": 862111,
      "postDate": "2020-05-26T12:30:34.783Z",
      "content": "<p>Hi there,\nI have another discussion topic:</p>\n\n<p>I have seen two general approaches sofar in the public notebooks:\nThe first passes a list of N images=tiles, and concatenates them before passing through the transfer learning pass.\nThe second approach creates a large image of the consisting tiles and then passes it through the whole network as one. Hence the image has the size sqrt(N) x sqrt(N).</p>\n\n<p>What are the pros and cons of both methods?\nCouldn't it be for example, that in the second method, the classifier learns something it shouldn't from the borders between the tiles in the image?</p>",
      "rawMarkdown": "Hi there,\nI have another discussion topic:\n\nI have seen two general approaches sofar in the public notebooks:\nThe first passes a list of N images=tiles, and concatenates them before passing through the transfer learning pass.\nThe second approach creates a large image of the consisting tiles and then passes it through the whole network as one. Hence the image has the size sqrt(N) x sqrt(N).\n\nWhat are the pros and cons of both methods?\nCouldn't it be for example, that in the second method, the classifier learns something it shouldn't from the borders between the tiles in the image?",
      "votes": 17
    },
    {
      "id": 864258,
      "postDate": "2020-05-27T23:01:20.287Z",
      "content": "<p>Regarding the second approach, in addition to boundary effect (which I'd expect to be small), the augmentation is applied a little bit differently. If tiles are combined into an image before augmenting, the same augmentation is applied to all of them. I do not have a solid evidence that it is bad since I didn't run corresponding checks, but I have an expectation that training would go worse if all images in a batch are augmented in the same way instead of using an individual augmentation to each image. He the effect is similar despite the same augmentation is applied only to all tiles of an individual image. Meanwhile, if tiles are combined into a large image after augmenting, the only difference between the approaches is just the tile boundary effect, and, therefore, the results should be quite identical.</p>",
      "rawMarkdown": "Regarding the second approach, in addition to boundary effect (which I'd expect to be small), the augmentation is applied a little bit differently. If tiles are combined into an image before augmenting, the same augmentation is applied to all of them. I do not have a solid evidence that it is bad since I didn't run corresponding checks, but I have an expectation that training would go worse if all images in a batch are augmented in the same way instead of using an individual augmentation to each image. He the effect is similar despite the same augmentation is applied only to all tiles of an individual image. Meanwhile, if tiles are combined into a large image after augmenting, the only difference between the approaches is just the tile boundary effect, and, therefore, the results should be quite identical.",
      "votes": 6
    },
    {
      "id": 867722,
      "postDate": "2020-05-30T14:57:20.050Z",
      "content": "<p>Large single image made of tiles here (LB 0.87). Mainly due to GPU memory issues (I'm mostly running on an RTX2070), I'm still sticking to EfficientNet*<em>B0</em>*!</p>",
      "rawMarkdown": "Large single image made of tiles here (LB 0.87). Mainly due to GPU memory issues (I'm mostly running on an RTX2070), I'm still sticking to EfficientNet**B0**!",
      "votes": 1
    },
    {
      "id": 862306,
      "postDate": "2020-05-26T14:22:41.753Z",
      "content": "<p>Do people get good results with the second approach ? Because to me it doesn't look good... One important aspect of multi instance learning is that you usually want your model to be permutation independent (the order of tiles should not matter). Stitching tiles together make it permutation dependent once you use a CNN on top of it. Maybe if you combine it with permutation can you make the model better though but I'd be very surprised if that method beats the first one.</p>",
      "rawMarkdown": "Do people get good results with the second approach ? Because to me it doesn't look good... One important aspect of multi instance learning is that you usually want your model to be permutation independent (the order of tiles should not matter). Stitching tiles together make it permutation dependent once you use a CNN on top of it. Maybe if you combine it with permutation can you make the model better though but I'd be very surprised if that method beats the first one.",
      "votes": 1,
      "replies": [
        {
          "id": 862335,
          "postDate": "2020-05-26T14:45:00.767Z",
          "content": "<p>What would you consider a good results?\nFor the second, one can use stochastic approach to concatenate and so no permutation dependencies will arise.</p>",
          "rawMarkdown": "What would you consider a good results?\nFor the second, one can use stochastic approach to concatenate and so no permutation dependencies will arise.",
          "votes": 1
        },
        {
          "id": 862347,
          "postDate": "2020-05-26T14:51:13.273Z",
          "content": "<p>On par or better than the other idea.</p>",
          "rawMarkdown": "On par or better than the other idea."
        },
        {
          "id": 862536,
          "postDate": "2020-05-26T16:38:29.823Z",
          "content": "<p>My approach stitches together all the tiles into a large rectangle image since straight horizontal/vertical concat is unable to pass through pretrained models without bad results. The approach is similar to what was used here: <a href=\"https://www.kaggle.com/yasufuminakama/panda-se-resnext50-regression-baseline\">https://www.kaggle.com/yasufuminakama/panda-se-resnext50-regression-baseline</a> (I think that's what the second approach your speaking of is)</p>",
          "rawMarkdown": "My approach stitches together all the tiles into a large rectangle image since straight horizontal/vertical concat is unable to pass through pretrained models without bad results. The approach is similar to what was used here: https://www.kaggle.com/yasufuminakama/panda-se-resnext50-regression-baseline (I think that's what the second approach your speaking of is)",
          "votes": 1
        },
        {
          "id": 862552,
          "postDate": "2020-05-26T16:51:24.203Z",
          "content": "<p>Thank you for your answers!</p>\n\n<p>Yes, in my head multi instance learning seems to be the more suited approach.</p>\n\n<p>On the other hand, the gleason score is predicted by telling the ammount of 1st and 2nd level cancer. Hence, I hope the boundaries won't do too much damage. </p>\n\n<p>I will report back the results here! </p>",
          "rawMarkdown": "Thank you for your answers!\n\nYes, in my head multi instance learning seems to be the more suited approach.\n\nOn the other hand, the gleason score is predicted by telling the ammount of 1st and 2nd level cancer. Hence, I hope the boundaries won't do too much damage. \n\nI will report back the results here! "
        },
        {
          "id": 862561,
          "postDate": "2020-05-26T16:56:17.343Z",
          "content": "<p>Yes, exactly. This is the Kernel I got the same idea from.\nWould you mind sharing what scores you get for that? </p>",
          "rawMarkdown": "Yes, exactly. This is the Kernel I got the same idea from.\nWould you mind sharing what scores you get for that? "
        },
        {
          "id": 862573,
          "postDate": "2020-05-26T17:04:17.827Z",
          "content": "<p>I've only done one experiment with it but so far it has been promising.\nWith single fold seresnext50\nCV: .810\nLB: .85\nUsing intermediate resolution so the created images are rather large</p>",
          "rawMarkdown": "I've only done one experiment with it but so far it has been promising.\nWith single fold seresnext50\nCV: .810\nLB: .85\nUsing intermediate resolution so the created images are rather large",
          "votes": 3
        },
        {
          "id": 862591,
          "postDate": "2020-05-26T17:21:05.477Z",
          "content": "<p>That is indeed good! May I ask what the picture and tile size is in this case? </p>",
          "rawMarkdown": "That is indeed good! May I ask what the picture and tile size is in this case? ",
          "votes": 1
        },
        {
          "id": 862634,
          "postDate": "2020-05-26T17:50:54.827Z",
          "content": "<p>I'm using iafoss 's script with no changes. 32 tiles all 256x256 stitched into single image that's 8 tiles by 4 tiles.</p>",
          "rawMarkdown": "I'm using iafoss 's script with no changes. 32 tiles all 256x256 stitched into single image that's 8 tiles by 4 tiles.",
          "votes": 2
        },
        {
          "id": 862652,
          "postDate": "2020-05-26T18:04:01.923Z",
          "content": "<p>Thank you! Pardon my ignorance for the next question:</p>\n\n<p>I currently don't fully understand where you get the 32x256x256 tiles from. From what I see, iafoss has only a Kernel that produces 16x128x128 tiles. If I try his kernel with your aforementioned sizes, I get basically tile almost empty? Thus, I believe there are different TIFF images, or they can be opened with a higher resolution?</p>\n\n<p>Thank you already in advanced for clarifying it...</p>",
          "rawMarkdown": "Thank you! Pardon my ignorance for the next question:\n\nI currently don't fully understand where you get the 32x256x256 tiles from. From what I see, iafoss has only a Kernel that produces 16x128x128 tiles. If I try his kernel with your aforementioned sizes, I get basically tile almost empty? Thus, I believe there are different TIFF images, or they can be opened with a higher resolution?\n\nThank you already in advanced for clarifying it..."
        },
        {
          "id": 862654,
          "postDate": "2020-05-26T18:06:53.620Z",
          "content": "<p>The TIFF files hold the same image but at 3 different resolutions. When you load the tiff file it returns the three images and you just index which image you want. That kernal indexes image zero which is the lowest resolution. Simple change the index from zero to one and it'll tile the intermediate images.</p>",
          "rawMarkdown": "The TIFF files hold the same image but at 3 different resolutions. When you load the tiff file it returns the three images and you just index which image you want. That kernal indexes image zero which is the lowest resolution. Simple change the index from zero to one and it'll tile the intermediate images.",
          "votes": 3
        },
        {
          "id": 862668,
          "postDate": "2020-05-26T18:17:46.283Z",
          "content": "<p>THANK YOU! This makes everything clear now :)</p>",
          "rawMarkdown": "THANK YOU! This makes everything clear now :)"
        },
        {
          "id": 862682,
          "postDate": "2020-05-26T18:31:50.580Z",
          "content": "<p>With 128x128x36 tiles as a concatenated single rectangle image I get 0.83 CV/LB with resnet50</p>",
          "rawMarkdown": "With 128x128x36 tiles as a concatenated single rectangle image I get 0.83 CV/LB with resnet50\n",
          "votes": 2
        },
        {
          "id": 862775,
          "postDate": "2020-05-26T20:14:25.417Z",
          "content": "<blockquote>\n  <p><strong>GreatGameDota wrote:</strong></p>\n  \n  <p>I'm using iafoss 's script with no changes. 32 tiles all 256x256 stitched into single image that's 8 tiles by 4 tiles.</p>\n</blockquote>\n\n<p>That's quite a big image. What hardware are you using and/or at what batch size.</p>",
          "rawMarkdown": "&gt; **GreatGameDota wrote:**\n&gt; \n&gt; I'm using iafoss 's script with no changes. 32 tiles all 256x256 stitched into single image that's 8 tiles by 4 tiles.\n\nThat's quite a big image. What hardware are you using and/or at what batch size."
        },
        {
          "id": 862783,
          "postDate": "2020-05-26T20:24:23.467Z",
          "content": "<p>I don't have a big enough local gpu so I'm using google colab's Tesla P100s (not colab pro) with a batch size of 2.</p>",
          "rawMarkdown": "I don't have a big enough local gpu so I'm using google colab's Tesla P100s (not colab pro) with a batch size of 2.",
          "votes": 1
        },
        {
          "id": 863170,
          "postDate": "2020-05-27T05:59:29.577Z",
          "rawMarkdown": "",
          "isDeleted": true
        },
        {
          "id": 863216,
          "postDate": "2020-05-27T06:46:13.320Z",
          "content": "<p>May I ask how you store your tiles when using colab ? \nI want to generate 32 tiles but kaggle kernel output is limited to something like 5go so it won't work (create dataset from output and use api from colab). I'm trying to compete only with kaggle and colab. Maybe i'm missing something</p>",
          "rawMarkdown": "May I ask how you store your tiles when using colab ? \nI want to generate 32 tiles but kaggle kernel output is limited to something like 5go so it won't work (create dataset from output and use api from colab). I'm trying to compete only with kaggle and colab. Maybe i'm missing something",
          "votes": 1
        },
        {
          "id": 863564,
          "postDate": "2020-05-27T11:57:06.050Z",
          "content": "<p>Hi <a href=\"/greatgamedota\">@greatgamedota</a>, I get I/O error when accessing files from directories on colab. Do u mind telling step by step how u have arranged the files to avoid this error? I have made separate directories for tiles of each image. I/O error is gone but then the model is too slow because it has to access different directories for each image. pls help.</p>",
          "rawMarkdown": "Hi @greatgamedota, I get I/O error when accessing files from directories on colab. Do u mind telling step by step how u have arranged the files to avoid this error? I have made separate directories for tiles of each image. I/O error is gone but then the model is too slow because it has to access different directories for each image. pls help."
        },
        {
          "id": 863635,
          "postDate": "2020-05-27T13:03:29.267Z",
          "content": "<p><a href=\"/agnikbanerjee\">@agnikbanerjee</a> I set training for 10 epochs but it only gets to around 9 depending on the session.</p>\n\n<p><a href=\"/alexj21\">@alexj21</a> I load all the base images from a kaggle dataset into colab and then generate the tiles while training.</p>\n\n<p><a href=\"/virajbagal\">@virajbagal</a> Use the kaggle api to download the files from a kaggle dataset, in the kaggle dataset just have all the images as jpg/png files and you should be able to work with them fine.</p>",
          "rawMarkdown": "@agnikbanerjee I set training for 10 epochs but it only gets to around 9 depending on the session.\n\n@alexj21 I load all the base images from a kaggle dataset into colab and then generate the tiles while training.\n\n@virajbagal Use the kaggle api to download the files from a kaggle dataset, in the kaggle dataset just have all the images as jpg/png files and you should be able to work with them fine.",
          "votes": 2
        },
        {
          "id": 863640,
          "postDate": "2020-05-27T13:10:10.093Z",
          "content": "<p>Thanks! Don't you have to download all the images again every time you restart the notebook on colab? And if I and not mistaken, the dataset is 430 GB, does that even have enough space?</p>",
          "rawMarkdown": "Thanks! Don't you have to download all the images again every time you restart the notebook on colab? And if I and not mistaken, the dataset is 430 GB, does that even have enough space?"
        },
        {
          "id": 863647,
          "postDate": "2020-05-27T13:14:45.497Z",
          "content": "<p>Using <a href=\"https://www.kaggle.com/lopuhin/panda-2020-level-1-2\">this dataset</a> its only 10GB which only takes a few minutes to download into the notebook. And yes you have to redownload everytime the runtime is reset which isn't that big of a deal.</p>",
          "rawMarkdown": "Using [this dataset](https://www.kaggle.com/lopuhin/panda-2020-level-1-2) its only 10GB which only takes a few minutes to download into the notebook. And yes you have to redownload everytime the runtime is reset which isn't that big of a deal.",
          "votes": 2
        },
        {
          "id": 863655,
          "postDate": "2020-05-27T13:20:55.677Z",
          "content": "<p>Helpful Dataset! Thank you very much! :)</p>",
          "rawMarkdown": "Helpful Dataset! Thank you very much! :)"
        },
        {
          "id": 863916,
          "postDate": "2020-05-27T16:36:00.890Z",
          "content": "<p>thanks <a href=\"/greatgamedota\">@greatgamedota</a> very helpful dataset indeed. \nBTW1 for those who just started with colab you can directly unzip the dataset with kaggle API using --unzip flag. \nBTW2 if you have data in drive and want to unzip in colab, sometimes it fails with !unzip (too large zip file), you can use p7zip instead</p>",
          "rawMarkdown": "thanks @greatgamedota very helpful dataset indeed. \nBTW1 for those who just started with colab you can directly unzip the dataset with kaggle API using --unzip flag. \nBTW2 if you have data in drive and want to unzip in colab, sometimes it fails with !unzip (too large zip file), you can use p7zip instead",
          "votes": 1
        }
      ]
    },
    {
      "id": 862229,
      "postDate": "2020-05-26T13:44:36.600Z",
      "content": "<p>Hey! Good question though. I've used both approaches and still in the process of experiments with the first you mentioned (list of tiles). I believe they would work about the same. \n1. The only problem I can see with 2nd (concatenation) approach is that you need to fit the image into GPU memory with a batch size at least 1 and you are a bit stuck with the square size of the image. For instance, you can use 384x384x9 (3x3 square concatenated image) and fit it into memory, but it is not enough hardware (hypothetically) for the next size with the 16 tiles. With a list approach you can still try 10, 12 and so on number of tiles. I think you can put more tiles into GPU with list-like approach though!\n2. IMO, should not be a problem if size of the tile is not too small. The task at hand is about if Gleason patterns presented in the slide and what percentage of the tissue they are. So, I believe there is not huge spatial dependencies here! </p>",
      "rawMarkdown": "Hey! Good question though. I've used both approaches and still in the process of experiments with the first you mentioned (list of tiles). I believe they would work about the same. \n1. The only problem I can see with 2nd (concatenation) approach is that you need to fit the image into GPU memory with a batch size at least 1 and you are a bit stuck with the square size of the image. For instance, you can use 384x384x9 (3x3 square concatenated image) and fit it into memory, but it is not enough hardware (hypothetically) for the next size with the 16 tiles. With a list approach you can still try 10, 12 and so on number of tiles. I think you can put more tiles into GPU with list-like approach though!\n2. IMO, should not be a problem if size of the tile is not too small. The task at hand is about if Gleason patterns presented in the slide and what percentage of the tissue they are. So, I believe there is not huge spatial dependencies here! ",
      "votes": 1,
      "replies": [
        {
          "id": 862554,
          "postDate": "2020-05-26T16:53:14.760Z",
          "content": "<p>Both excellent points. I am currently using an image of 16x132x132 - &gt; 528x528 (for EffNetB6), and that is just a very big network and a very big picture. Using the list method allows me to use smaller pictures and smaller networks like EffNetB0</p>",
          "rawMarkdown": "Both excellent points. I am currently using an image of 16x132x132 - &gt; 528x528 (for EffNetB6), and that is just a very big network and a very big picture. Using the list method allows me to use smaller pictures and smaller networks like EffNetB0"
        }
      ]
    },
    {
      "id": 868918,
      "postDate": "2020-05-31T15:06:20.647Z",
      "content": "<p><a href=\"/iafoss\">@iafoss</a> Hi ,as you are expert in tiling . Need feedback that could help me as well .Could you throw light on  inputting asymmetric image created form 128x128x36, by cocatenation image will be of size 512 x 1152 (approx), \nAll network usually take square image.\nThanks for help in advance.</p>",
      "rawMarkdown": "@iafoss Hi ,as you are expert in tiling . Need feedback that could help me as well .Could you throw light on  inputting asymmetric image created form 128x128x36, by cocatenation image will be of size 512 x 1152 (approx), \nAll network usually take square image.\nThanks for help in advance.",
      "replies": [
        {
          "id": 869022,
          "postDate": "2020-05-31T16:44:59.710Z",
          "content": "<p>I think if u do augmentation before concatenation, rectangular shape shouldn't be a problem. Sometimes, rescaling to square images for regular training may work better when one dealing with elongated objects, so the x and y scale of produced features are the same. However, here it is not the case, and the x and y scale of the features is already the same without squeezing the images.</p>",
          "rawMarkdown": "I think if u do augmentation before concatenation, rectangular shape shouldn't be a problem. Sometimes, rescaling to square images for regular training may work better when one dealing with elongated objects, so the x and y scale of produced features are the same. However, here it is not the case, and the x and y scale of the features is already the same without squeezing the images.",
          "votes": 2
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 864258,
      "author_name": "Iafoss",
      "author_url": "",
      "post_date": "2020-05-27T23:01:20.287000",
      "content": "<p>Regarding the second approach, in addition to boundary effect (which I'd expect to be small), the augmentation is applied a little bit differently. If tiles are combined into an image before augmenting, the same augmentation is applied to all of them. I do not have a solid evidence that it is bad since I didn't run corresponding checks, but I have an expectation that training would go worse if all images in a batch are augmented in the same way instead of using an individual augmentation to each image. He the effect is similar despite the same augmentation is applied only to all tiles of an individual image. Meanwhile, if tiles are combined into a large image after augmenting, the only difference between the approaches is just the tile boundary effect, and, therefore, the results should be quite identical.</p>",
      "votes": 6,
      "replies": []
    },
    {
      "id": 867722,
      "author_name": "Alex",
      "author_url": "",
      "post_date": "2020-05-30T14:57:20.050000",
      "content": "<p>Large single image made of tiles here (LB 0.87). Mainly due to GPU memory issues (I'm mostly running on an RTX2070), I'm still sticking to EfficientNet*<em>B0</em>*!</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 862306,
      "author_name": "Arnaud Roussel",
      "author_url": "",
      "post_date": "2020-05-26T14:22:41.753000",
      "content": "<p>Do people get good results with the second approach ? Because to me it doesn't look good... One important aspect of multi instance learning is that you usually want your model to be permutation independent (the order of tiles should not matter). Stitching tiles together make it permutation dependent once you use a CNN on top of it. Maybe if you combine it with permutation can you make the model better though but I'd be very surprised if that method beats the first one.</p>",
      "votes": 1,
      "replies": [
        {
          "id": 862335,
          "author_name": "A.Demyanchuk",
          "author_url": "",
          "post_date": "2020-05-26T14:45:00.767000",
          "content": "<p>What would you consider a good results?\nFor the second, one can use stochastic approach to concatenate and so no permutation dependencies will arise.</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 862347,
          "author_name": "Arnaud Roussel",
          "author_url": "",
          "post_date": "2020-05-26T14:51:13.273000",
          "content": "<p>On par or better than the other idea.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 862536,
          "author_name": "GreatGameDota",
          "author_url": "",
          "post_date": "2020-05-26T16:38:29.823000",
          "content": "<p>My approach stitches together all the tiles into a large rectangle image since straight horizontal/vertical concat is unable to pass through pretrained models without bad results. The approach is similar to what was used here: <a href=\"https://www.kaggle.com/yasufuminakama/panda-se-resnext50-regression-baseline\">https://www.kaggle.com/yasufuminakama/panda-se-resnext50-regression-baseline</a> (I think that's what the second approach your speaking of is)</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 862552,
          "author_name": "Claudio Fanconi",
          "author_url": "",
          "post_date": "2020-05-26T16:51:24.203000",
          "content": "<p>Thank you for your answers!</p>\n\n<p>Yes, in my head multi instance learning seems to be the more suited approach.</p>\n\n<p>On the other hand, the gleason score is predicted by telling the ammount of 1st and 2nd level cancer. Hence, I hope the boundaries won't do too much damage. </p>\n\n<p>I will report back the results here! </p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 862561,
          "author_name": "Claudio Fanconi",
          "author_url": "",
          "post_date": "2020-05-26T16:56:17.343000",
          "content": "<p>Yes, exactly. This is the Kernel I got the same idea from.\nWould you mind sharing what scores you get for that? </p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 862573,
          "author_name": "GreatGameDota",
          "author_url": "",
          "post_date": "2020-05-26T17:04:17.827000",
          "content": "<p>I've only done one experiment with it but so far it has been promising.\nWith single fold seresnext50\nCV: .810\nLB: .85\nUsing intermediate resolution so the created images are rather large</p>",
          "votes": 3,
          "replies": []
        },
        {
          "id": 862591,
          "author_name": "Claudio Fanconi",
          "author_url": "",
          "post_date": "2020-05-26T17:21:05.477000",
          "content": "<p>That is indeed good! May I ask what the picture and tile size is in this case? </p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 862634,
          "author_name": "GreatGameDota",
          "author_url": "",
          "post_date": "2020-05-26T17:50:54.827000",
          "content": "<p>I'm using iafoss 's script with no changes. 32 tiles all 256x256 stitched into single image that's 8 tiles by 4 tiles.</p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 862652,
          "author_name": "Claudio Fanconi",
          "author_url": "",
          "post_date": "2020-05-26T18:04:01.923000",
          "content": "<p>Thank you! Pardon my ignorance for the next question:</p>\n\n<p>I currently don't fully understand where you get the 32x256x256 tiles from. From what I see, iafoss has only a Kernel that produces 16x128x128 tiles. If I try his kernel with your aforementioned sizes, I get basically tile almost empty? Thus, I believe there are different TIFF images, or they can be opened with a higher resolution?</p>\n\n<p>Thank you already in advanced for clarifying it...</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 862654,
          "author_name": "GreatGameDota",
          "author_url": "",
          "post_date": "2020-05-26T18:06:53.620000",
          "content": "<p>The TIFF files hold the same image but at 3 different resolutions. When you load the tiff file it returns the three images and you just index which image you want. That kernal indexes image zero which is the lowest resolution. Simple change the index from zero to one and it'll tile the intermediate images.</p>",
          "votes": 3,
          "replies": []
        },
        {
          "id": 862668,
          "author_name": "Claudio Fanconi",
          "author_url": "",
          "post_date": "2020-05-26T18:17:46.283000",
          "content": "<p>THANK YOU! This makes everything clear now :)</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 862682,
          "author_name": "A.Demyanchuk",
          "author_url": "",
          "post_date": "2020-05-26T18:31:50.580000",
          "content": "<p>With 128x128x36 tiles as a concatenated single rectangle image I get 0.83 CV/LB with resnet50</p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 862775,
          "author_name": "Arnaud Roussel",
          "author_url": "",
          "post_date": "2020-05-26T20:14:25.417000",
          "content": "<blockquote>\n  <p><strong>GreatGameDota wrote:</strong></p>\n  \n  <p>I'm using iafoss 's script with no changes. 32 tiles all 256x256 stitched into single image that's 8 tiles by 4 tiles.</p>\n</blockquote>\n\n<p>That's quite a big image. What hardware are you using and/or at what batch size.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 862783,
          "author_name": "GreatGameDota",
          "author_url": "",
          "post_date": "2020-05-26T20:24:23.467000",
          "content": "<p>I don't have a big enough local gpu so I'm using google colab's Tesla P100s (not colab pro) with a batch size of 2.</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 863170,
          "author_name": "",
          "author_url": "",
          "post_date": "2020-05-27T05:59:29.577000",
          "content": "",
          "votes": 0,
          "replies": []
        },
        {
          "id": 863216,
          "author_name": "Alex",
          "author_url": "",
          "post_date": "2020-05-27T06:46:13.320000",
          "content": "<p>May I ask how you store your tiles when using colab ? \nI want to generate 32 tiles but kaggle kernel output is limited to something like 5go so it won't work (create dataset from output and use api from colab). I'm trying to compete only with kaggle and colab. Maybe i'm missing something</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 863564,
          "author_name": "Viraj Bagal",
          "author_url": "",
          "post_date": "2020-05-27T11:57:06.050000",
          "content": "<p>Hi <a href=\"/greatgamedota\">@greatgamedota</a>, I get I/O error when accessing files from directories on colab. Do u mind telling step by step how u have arranged the files to avoid this error? I have made separate directories for tiles of each image. I/O error is gone but then the model is too slow because it has to access different directories for each image. pls help.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 863635,
          "author_name": "GreatGameDota",
          "author_url": "",
          "post_date": "2020-05-27T13:03:29.267000",
          "content": "<p><a href=\"/agnikbanerjee\">@agnikbanerjee</a> I set training for 10 epochs but it only gets to around 9 depending on the session.</p>\n\n<p><a href=\"/alexj21\">@alexj21</a> I load all the base images from a kaggle dataset into colab and then generate the tiles while training.</p>\n\n<p><a href=\"/virajbagal\">@virajbagal</a> Use the kaggle api to download the files from a kaggle dataset, in the kaggle dataset just have all the images as jpg/png files and you should be able to work with them fine.</p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 863640,
          "author_name": "Claudio Fanconi",
          "author_url": "",
          "post_date": "2020-05-27T13:10:10.093000",
          "content": "<p>Thanks! Don't you have to download all the images again every time you restart the notebook on colab? And if I and not mistaken, the dataset is 430 GB, does that even have enough space?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 863647,
          "author_name": "GreatGameDota",
          "author_url": "",
          "post_date": "2020-05-27T13:14:45.497000",
          "content": "<p>Using <a href=\"https://www.kaggle.com/lopuhin/panda-2020-level-1-2\">this dataset</a> its only 10GB which only takes a few minutes to download into the notebook. And yes you have to redownload everytime the runtime is reset which isn't that big of a deal.</p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 863655,
          "author_name": "Claudio Fanconi",
          "author_url": "",
          "post_date": "2020-05-27T13:20:55.677000",
          "content": "<p>Helpful Dataset! Thank you very much! :)</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 863916,
          "author_name": "Alex",
          "author_url": "",
          "post_date": "2020-05-27T16:36:00.890000",
          "content": "<p>thanks <a href=\"/greatgamedota\">@greatgamedota</a> very helpful dataset indeed. \nBTW1 for those who just started with colab you can directly unzip the dataset with kaggle API using --unzip flag. \nBTW2 if you have data in drive and want to unzip in colab, sometimes it fails with !unzip (too large zip file), you can use p7zip instead</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 862229,
      "author_name": "A.Demyanchuk",
      "author_url": "",
      "post_date": "2020-05-26T13:44:36.600000",
      "content": "<p>Hey! Good question though. I've used both approaches and still in the process of experiments with the first you mentioned (list of tiles). I believe they would work about the same. \n1. The only problem I can see with 2nd (concatenation) approach is that you need to fit the image into GPU memory with a batch size at least 1 and you are a bit stuck with the square size of the image. For instance, you can use 384x384x9 (3x3 square concatenated image) and fit it into memory, but it is not enough hardware (hypothetically) for the next size with the 16 tiles. With a list approach you can still try 10, 12 and so on number of tiles. I think you can put more tiles into GPU with list-like approach though!\n2. IMO, should not be a problem if size of the tile is not too small. The task at hand is about if Gleason patterns presented in the slide and what percentage of the tissue they are. So, I believe there is not huge spatial dependencies here! </p>",
      "votes": 1,
      "replies": [
        {
          "id": 862554,
          "author_name": "Claudio Fanconi",
          "author_url": "",
          "post_date": "2020-05-26T16:53:14.760000",
          "content": "<p>Both excellent points. I am currently using an image of 16x132x132 - &gt; 528x528 (for EffNetB6), and that is just a very big network and a very big picture. Using the list method allows me to use smaller pictures and smaller networks like EffNetB0</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 868918,
      "author_name": "Rajnish Chauhan",
      "author_url": "",
      "post_date": "2020-05-31T15:06:20.647000",
      "content": "<p><a href=\"/iafoss\">@iafoss</a> Hi ,as you are expert in tiling . Need feedback that could help me as well .Could you throw light on  inputting asymmetric image created form 128x128x36, by cocatenation image will be of size 512 x 1152 (approx), \nAll network usually take square image.\nThanks for help in advance.</p>",
      "votes": 0,
      "replies": [
        {
          "id": 869022,
          "author_name": "Iafoss",
          "author_url": "",
          "post_date": "2020-05-31T16:44:59.710000",
          "content": "<p>I think if u do augmentation before concatenation, rectangular shape shouldn't be a problem. Sometimes, rescaling to square images for regular training may work better when one dealing with elongated objects, so the x and y scale of produced features are the same. However, here it is not the case, and the x and y scale of the features is already the same without squeezing the images.</p>",
          "votes": 2,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "862111": "Hi there,\nI have another discussion topic:\n\nI have seen two general approaches sofar in the public notebooks:\nThe first passes a list of N images=tiles, and concatenates them before passing through the transfer learning pass.\nThe second approach creates a large image of the consisting tiles and then passes it through the whole network as one. Hence the image has the size sqrt(N) x sqrt(N).\n\nWhat are the pros and cons of both methods?\nCouldn't it be for example, that in the second method, the classifier learns something it shouldn't from the borders between the tiles in the image?",
    "864258": "Regarding the second approach, in addition to boundary effect (which I'd expect to be small), the augmentation is applied a little bit differently. If tiles are combined into an image before augmenting, the same augmentation is applied to all of them. I do not have a solid evidence that it is bad since I didn't run corresponding checks, but I have an expectation that training would go worse if all images in a batch are augmented in the same way instead of using an individual augmentation to each image. He the effect is similar despite the same augmentation is applied only to all tiles of an individual image. Meanwhile, if tiles are combined into a large image after augmenting, the only difference between the approaches is just the tile boundary effect, and, therefore, the results should be quite identical.",
    "867722": "Large single image made of tiles here (LB 0.87). Mainly due to GPU memory issues (I'm mostly running on an RTX2070), I'm still sticking to EfficientNet**B0**!",
    "862306": "Do people get good results with the second approach ? Because to me it doesn't look good... One important aspect of multi instance learning is that you usually want your model to be permutation independent (the order of tiles should not matter). Stitching tiles together make it permutation dependent once you use a CNN on top of it. Maybe if you combine it with permutation can you make the model better though but I'd be very surprised if that method beats the first one.",
    "862229": "Hey! Good question though. I've used both approaches and still in the process of experiments with the first you mentioned (list of tiles). I believe they would work about the same. \n1. The only problem I can see with 2nd (concatenation) approach is that you need to fit the image into GPU memory with a batch size at least 1 and you are a bit stuck with the square size of the image. For instance, you can use 384x384x9 (3x3 square concatenated image) and fit it into memory, but it is not enough hardware (hypothetically) for the next size with the 16 tiles. With a list approach you can still try 10, 12 and so on number of tiles. I think you can put more tiles into GPU with list-like approach though!\n2. IMO, should not be a problem if size of the tile is not too small. The task at hand is about if Gleason patterns presented in the slide and what percentage of the tissue they are. So, I believe there is not huge spatial dependencies here! ",
    "868918": "@iafoss Hi ,as you are expert in tiling . Need feedback that could help me as well .Could you throw light on  inputting asymmetric image created form 128x128x36, by cocatenation image will be of size 512 x 1152 (approx), \nAll network usually take square image.\nThanks for help in advance."
  }
}