{
  "id": 126553,
  "title": "[Curiously Solved]Submission Errors",
  "url": "/competitions/bengaliai-cv19/discussion/126553",
  "author_name": "",
  "post_date": "2020-01-18T09:56:27.710081900Z",
  "votes": 3,
  "comment_count": 19,
  "views": 0,
  "content": "<p>Hi, everyone! Been struggling to make a successful submission. There are the timeouts, kaggle error, etc. So I decide to give the discussion a try.</p>\n\n<p>Here is a kernel I forked and edited. \n<a href=\"https://www.kaggle.com/roguekk007/another-stab\">https://www.kaggle.com/roguekk007/another-stab</a>\nThe resnet34 achieves .970 CV locally, but when running it I got <strong>submission CSV not found</strong>. I am running at 224x224 resolution which I found helps. </p>\n\n<p>Commiting the kernel gives me a submission.csv. Why is there this error?\nAny help is appreciated, thanks👍 </p>",
  "messages": [
    {
      "id": "722241",
      "postDate": "01/18/2020 09:56:27",
      "content": "<p>Hi, everyone! Been struggling to make a successful submission. There are the timeouts, kaggle error, etc. So I decide to give the discussion a try.</p>\n\n<p>Here is a kernel I forked and edited. \n<a href=\"https://www.kaggle.com/roguekk007/another-stab\">https://www.kaggle.com/roguekk007/another-stab</a>\nThe resnet34 achieves .970 CV locally, but when running it I got <strong>submission CSV not found</strong>. I am running at 224x224 resolution which I found helps. </p>\n\n<p>Commiting the kernel gives me a submission.csv. Why is there this error?\nAny help is appreciated, thanks👍 </p>",
      "rawMarkdown": "Hi, everyone! Been struggling to make a successful submission. There are the timeouts, kaggle error, etc. So I decide to give the discussion a try.\n\nHere is a kernel I forked and edited. \nhttps://www.kaggle.com/roguekk007/another-stab\nThe resnet34 achieves .970 CV locally, but when running it I got **submission CSV not found**. I am running at 224x224 resolution which I found helps. \n\nCommiting the kernel gives me a submission.csv. Why is there this error?\nAny help is appreciated, thanks👍",
      "votes": null
    },
    {
      "id": "722247",
      "postDate": "01/18/2020 10:04:54",
      "content": "<p>This code is not optimized yet. You probably ran out of memory or time. Try a test commit with the train parquet files to see where is the issue. </p>\n\n<p>You can find my optimization tips <a href=\"https://www.kaggle.com/c/bengaliai-cv19/discussion/126054\">here</a>. (Implementation notebook included)</p>",
      "rawMarkdown": "This code is not optimized yet. You probably ran out of memory or time. Try a test commit with the train parquet files to see where is the issue. \n\nYou can find my optimization tips [here](https://www.kaggle.com/c/bengaliai-cv19/discussion/126054). (Implementation notebook included)",
      "votes": null
    },
    {
      "id": "722259",
      "postDate": "01/18/2020 10:23:31",
      "content": "<p>Hi Peter, thanks for your answer! I was trying to keep the code minimal. It is probably not a timeout error I have received an explicit \"Notebook timeout error\" before. The \"Did not find CSV\" error is really confusing. I have read your optimization tips and found them very useful :)</p>",
      "rawMarkdown": "Hi Peter, thanks for your answer! I was trying to keep the code minimal. It is probably not a timeout error I have received an explicit \"Notebook timeout error\" before. The \"Did not find CSV\" error is really confusing. I have read your optimization tips and found them very useful :)",
      "votes": null
    },
    {
      "id": "722354",
      "postDate": "01/18/2020 13:01:34",
      "content": "<p>There, I also managed to get a submission scoring error...I think I just obtained a collection of all make-able kaggle submission errors in my log now :)</p>",
      "rawMarkdown": "There, I also managed to get a submission scoring error...I think I just obtained a collection of all make-able kaggle submission errors in my log now :)",
      "votes": null
    },
    {
      "id": "722872",
      "postDate": "01/19/2020 08:30:28",
      "content": "<p>This competition has two challenges. First of them is to make a submission :)</p>\n\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1696976%2F11388298dc71e325102614fd932723da%2F.png?generation=1579422596035225&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "This competition has two challenges. First of them is to make a submission :)\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1696976%2F11388298dc71e325102614fd932723da%2F.png?generation=1579422596035225&amp;alt=media)",
      "votes": null
    },
    {
      "id": "723141",
      "postDate": "01/19/2020 14:51:14",
      "content": "<p>There is no way to find out what exact exception was raised during submission. And I cannot reproduce it, since kernel's commit is successful. It would be really helpful to show the stack trace in this case, since there is no way to debug this issue.</p>\n\n<p><a href=\"/addisonhoward\">@addisonhoward</a> <a href=\"/sohier\">@sohier</a> </p>",
      "rawMarkdown": "There is no way to find out what exact exception was raised during submission. And I cannot reproduce it, since kernel's commit is successful. It would be really helpful to show the stack trace in this case, since there is no way to debug this issue.\n\n@addisonhoward @sohier",
      "votes": null
    },
    {
      "id": "723428",
      "postDate": "01/20/2020 02:52:31",
      "content": "<p>Exactly the same here! My commit kernel produces a valid submission but I got a \"submission CSV not found\" error. Debugging the submission process is really frustrating.\nLooking forward to solving this problem.\n<a href=\"/addisonhoward\">@addisonhoward</a> <a href=\"/sohier\">@sohier</a> </p>\n\n<p>Here is the tragic submission log for me\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1943421%2F8f9a6e3e0776692335d9660feb4f42cd%2Fsubmission_error.jpg?generation=1579488879291317&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "Exactly the same here! My commit kernel produces a valid submission but I got a \"submission CSV not found\" error. Debugging the submission process is really frustrating.\nLooking forward to solving this problem.\n@addisonhoward @sohier \n\nHere is the tragic submission log for me\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1943421%2F8f9a6e3e0776692335d9660feb4f42cd%2Fsubmission_error.jpg?generation=1579488879291317&amp;alt=media)",
      "votes": null
    },
    {
      "id": "723558",
      "postDate": "01/20/2020 06:42:05",
      "content": "<p>In order to avoid memory issues, i first saved the model as a h5 file. Now in my kernel i am loading this model making a prediction and submitting, even that results in Error, and no log is provided. Can someone help pls.</p>",
      "rawMarkdown": "In order to avoid memory issues, i first saved the model as a h5 file. Now in my kernel i am loading this model making a prediction and submitting, even that results in Error, and no log is provided. Can someone help pls.",
      "votes": null
    },
    {
      "id": "724318",
      "postDate": "01/21/2020 03:21:22",
      "content": "<p>Hi! I solved my submission error by doing 9 controlled experiments (yes, I failed 8 times) and 29 previously failed submissions👋 . Seems like the first challenge in the competition is indeed making a successful submission :) Here is what worked for me, hope it helps.\n        I found that the crop_resize function (which I edited a little) and transformation led to failure. <strong>I added a backup transform without crop_resize with try:...except:... and solved the problem.</strong> Single model which achieves .972 CV leads to my current position.</p>\n\n<p>Original Code (fails)\n```\nclass GraphemeDataset(Dataset):\n    def <strong>init</strong>(self, fname, transform):\n        self.df = pd.read_parquet(fname)\n        self.data = 255 - self.df.iloc[:, 1:].values.reshape(-1, HEIGHT, WIDTH).astype(np.uint8)\n        self.transform = transform</p>\n\n<pre><code>def __len__(self):\n    return len(self.data)\n\ndef __getitem__(self, idx):\n    name = self.df.iloc[idx,0]\n    img = self.data[idx].astype(np.uint8)\n    img = self.transform(image=img)['image']\n    return img, name\n</code></pre>\n\n<p>```</p>\n\n<p>Successful Code\n```\nclass GraphemeDataset(Dataset):\n    def <strong>init</strong>(self, fname, transform):\n        self.df = pd.read_parquet(fname)\n        self.data = self.df.iloc[:, 1:].values.reshape(-1, HEIGHT, WIDTH).astype(np.uint8)\n        self.transform = transform</p>\n\n<pre><code>def __len__(self):\n    return len(self.data)\n\ndef __getitem__(self, idx):\n    name = self.df.iloc[idx,0]\n    try:\n        img = 255 - self.data[idx].astype(np.uint8)\n        img = self.transform(image=img)['image']\n    except:\n        img = 255 - self.data[idx].astype(np.uint8)\n        img = backup_tsfm(image=img)['image']\n    return img, name\n</code></pre>\n\n<p>```</p>\n\n<p>Still investigating why crop-resize fails, though. Any hypotheses?\nHere is the code for my crop-resize and transformation\n```\ndef bbox(img):\n    rows = np.any(img, axis=1)\n    cols = np.any(img, axis=0)\n    rmin, rmax = np.where(rows)[0][[0, -1]]\n    cmin, cmax = np.where(cols)[0][[0, -1]]\n    return rmin, rmax, cmin, cmax</p>\n\n<p>def crop_resize(img0, size=SIZE, pad=8, cols=None, rows=None, force_apply=False):\n    #crop a box around pixels large than the threshold \n    #some images contain line at the sides\n    ymin,ymax,xmin,xmax = bbox(img0[5:-5,5:-5] &gt; 80)\n    #cropping may cut too much, so we need to add it back\n    xmin = xmin - 13 if (xmin &gt; 13) else 0\n    ymin = ymin - 10 if (ymin &gt; 10) else 0\n    xmax = xmax + 13 if (xmax &lt; WIDTH - 13) else WIDTH\n    ymax = ymax + 10 if (ymax &lt; HEIGHT - 10) else HEIGHT\n    img = img0[ymin:ymax,xmin:xmax]\n    #remove lo intensity pixels as noise\n    img[img &lt; 28] = 0\n    lx, ly = xmax-xmin,ymax-ymin\n    l = max(lx,ly) + pad\n    #make sure that the aspect ratio is kept in rescaling\n    img = np.pad(img, [((l-ly)//2,), ((l-lx)//2,)], mode='constant')\n    return cv2.resize(img,(size,size))</p>\n\n<p>tsfm = Compose([\n                Lambda(image=crop_resize),\n                Resize(SIZE, SIZE),\n                Normalize((.0855,),(.2,)),\n                ToTensor(),\n            ])\n```</p>",
      "rawMarkdown": "Hi! I solved my submission error by doing 9 controlled experiments (yes, I failed 8 times) and 29 previously failed submissions👋 . Seems like the first challenge in the competition is indeed making a successful submission :) Here is what worked for me, hope it helps.\n        I found that the crop_resize function (which I edited a little) and transformation led to failure. **I added a backup transform without crop_resize with try:...except:... and solved the problem.** Single model which achieves .972 CV leads to my current position.\n\nOriginal Code (fails)\n```\nclass GraphemeDataset(Dataset):\n    def __init__(self, fname, transform):\n        self.df = pd.read_parquet(fname)\n        self.data = 255 - self.df.iloc[:, 1:].values.reshape(-1, HEIGHT, WIDTH).astype(np.uint8)\n        self.transform = transform\n\n    def __len__(self):\n        return len(self.data)\n\n    def __getitem__(self, idx):\n        name = self.df.iloc[idx,0]\n        img = self.data[idx].astype(np.uint8)\n        img = self.transform(image=img)['image']\n        return img, name\n```\n\nSuccessful Code\n```\nclass GraphemeDataset(Dataset):\n    def __init__(self, fname, transform):\n        self.df = pd.read_parquet(fname)\n        self.data = self.df.iloc[:, 1:].values.reshape(-1, HEIGHT, WIDTH).astype(np.uint8)\n        self.transform = transform\n\n    def __len__(self):\n        return len(self.data)\n\n    def __getitem__(self, idx):\n        name = self.df.iloc[idx,0]\n        try:\n            img = 255 - self.data[idx].astype(np.uint8)\n            img = self.transform(image=img)['image']\n        except:\n            img = 255 - self.data[idx].astype(np.uint8)\n            img = backup_tsfm(image=img)['image']\n        return img, name\n```\n\nStill investigating why crop-resize fails, though. Any hypotheses?\nHere is the code for my crop-resize and transformation\n```\ndef bbox(img):\n    rows = np.any(img, axis=1)\n    cols = np.any(img, axis=0)\n    rmin, rmax = np.where(rows)[0][[0, -1]]\n    cmin, cmax = np.where(cols)[0][[0, -1]]\n    return rmin, rmax, cmin, cmax\n\ndef crop_resize(img0, size=SIZE, pad=8, cols=None, rows=None, force_apply=False):\n    #crop a box around pixels large than the threshold \n    #some images contain line at the sides\n    ymin,ymax,xmin,xmax = bbox(img0[5:-5,5:-5] &gt; 80)\n    #cropping may cut too much, so we need to add it back\n    xmin = xmin - 13 if (xmin &gt; 13) else 0\n    ymin = ymin - 10 if (ymin &gt; 10) else 0\n    xmax = xmax + 13 if (xmax &lt; WIDTH - 13) else WIDTH\n    ymax = ymax + 10 if (ymax &lt; HEIGHT - 10) else HEIGHT\n    img = img0[ymin:ymax,xmin:xmax]\n    #remove lo intensity pixels as noise\n    img[img &lt; 28] = 0\n    lx, ly = xmax-xmin,ymax-ymin\n    l = max(lx,ly) + pad\n    #make sure that the aspect ratio is kept in rescaling\n    img = np.pad(img, [((l-ly)//2,), ((l-lx)//2,)], mode='constant')\n    return cv2.resize(img,(size,size))\n\ntsfm = Compose([\n                Lambda(image=crop_resize),\n                Resize(SIZE, SIZE),\n                Normalize((.0855,),(.2,)),\n                ToTensor(),\n            ])\n```",
      "votes": null
    },
    {
      "id": "724963",
      "postDate": "01/21/2020 16:41:18",
      "content": "<p>it is really time consuming to debug uninformative errors like these given in the competition. we are data scientists not alchemists</p>",
      "rawMarkdown": "it is really time consuming to debug uninformative errors like these given in the competition. we are data scientists not alchemists",
      "votes": null
    },
    {
      "id": "725297",
      "postDate": "01/22/2020 01:25:44",
      "content": "<p><a href=\"/ma7555\">@ma7555</a> My suggestion is that you start from an easy-to-understand successful inference kernel then change it to your own submission kernel step-by-step. I did this for 8 times and finally succeeded. In retrospect it was only 2 days, though (8 submissions).</p>",
      "rawMarkdown": "ma7555 My suggestion is that you start from an easy-to-understand successful inference kernel then change it to your own submission kernel step-by-step. I did this for 8 times and finally succeeded. In retrospect it was only 2 days, though (8 submissions).",
      "votes": null
    },
    {
      "id": "725714",
      "postDate": "01/22/2020 12:28:19",
      "content": "<p>Same case for me as well but with an additional error. Not sure what I did wrong as commit only take about 400-500s.\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2116526%2Fc10a4c43fbda19be97406fd98a2b7c00%2FScreenshot%202020-01-21%20at%2012.38.23%20PM.png?generation=1579696072557804&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "Same case for me as well but with an additional error. Not sure what I did wrong as commit only take about 400-500s.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2116526%2Fc10a4c43fbda19be97406fd98a2b7c00%2FScreenshot%202020-01-21%20at%2012.38.23%20PM.png?generation=1579696072557804&amp;alt=media)",
      "votes": null
    },
    {
      "id": "727842",
      "postDate": "01/24/2020 05:33:55",
      "content": "<p>I ran into this myself -- my best guess is there must be some blank or extremely faint image in the test set, which causes the indexing in <code>bbox</code> to fail, since both <code>rows</code> and <code>cols</code> would be empty. I seem to have solved this by adding simple checks in <code>bbox</code>. Again frustrating to fix, but that's what I get for copying over code without thinking hard enough :P</p>",
      "rawMarkdown": "I ran into this myself -- my best guess is there must be some blank or extremely faint image in the test set, which causes the indexing in `bbox` to fail, since both `rows` and `cols` would be empty. I seem to have solved this by adding simple checks in `bbox`. Again frustrating to fix, but that's what I get for copying over code without thinking hard enough :P",
      "votes": null
    },
    {
      "id": "728727",
      "postDate": "01/25/2020 06:43:48",
      "content": "<p>welcome board.✌️ </p>",
      "rawMarkdown": "welcome board.✌️",
      "votes": null
    },
    {
      "id": "730084",
      "postDate": "01/27/2020 05:04:05",
      "content": "<p><a href=\"/roshanpadaki\">@roshanpadaki</a> but how could inference succeed here?\n<a href=\"https://www.kaggle.com/iafoss/grapheme-fast-ai-starter-inference\">https://www.kaggle.com/iafoss/grapheme-fast-ai-starter-inference</a></p>",
      "rawMarkdown": "roshanpadaki but how could inference succeed here?\nhttps://www.kaggle.com/iafoss/grapheme-fast-ai-starter-inference",
      "votes": null
    },
    {
      "id": "730133",
      "postDate": "01/27/2020 06:17:13",
      "content": "<p>I am wondering about the same thing, as fixing this problem could potentially help LB. Maybe because I changed some parameters? Did you change any? <a href=\"/roshanpadaki\">@roshanpadaki</a> </p>",
      "rawMarkdown": "I am wondering about the same thing, as fixing this problem could potentially help LB. Maybe because I changed some parameters? Did you change any? @roshanpadaki",
      "votes": null
    },
    {
      "id": "732689",
      "postDate": "01/30/2020 05:38:22",
      "content": "<p>Could I know what you did on backup_tsfm?\nJust resize image and do data augmentation?\nLooking forward to your reply</p>",
      "rawMarkdown": "Could I know what you did on backup_tsfm?\nJust resize image and do data augmentation?\nLooking forward to your reply",
      "votes": null
    },
    {
      "id": "735742",
      "postDate": "02/03/2020 12:10:07",
      "content": "<p><a href=\"/roguekk007\">@roguekk007</a> I think I understand now why his inference kernel works. simply because he normalized the image before calling the crop_resize so this fixed the <em>too faint image</em> problem...</p>",
      "rawMarkdown": "roguekk007 I think I understand now why his inference kernel works. simply because he normalized the image before calling the crop_resize so this fixed the *too faint image* problem...",
      "votes": null
    },
    {
      "id": "744275",
      "postDate": "02/12/2020 17:35:48",
      "content": "<p>I've been having huge issues with this and I couldn't even submit 1's.  So far I found that when I go to reshape the data, that seems to be the breaking point for me.  I created a public notebook related to my findings.\n<a href=\"https://www.kaggle.com/yeayates21/cant-submit-1s-whats-wrong-please-help\">https://www.kaggle.com/yeayates21/cant-submit-1s-whats-wrong-please-help</a></p>",
      "rawMarkdown": "I've been having huge issues with this and I couldn't even submit 1's.  So far I found that when I go to reshape the data, that seems to be the breaking point for me.  I created a public notebook related to my findings.\nhttps://www.kaggle.com/yeayates21/cant-submit-1s-whats-wrong-please-help",
      "votes": null
    },
    {
      "id": "744280",
      "postDate": "02/12/2020 17:40:01",
      "content": "<p>I think I came to the same conclusion that reshaping the parquet data causes submission to fail.  I've been having huge issues with this and I couldn't even submit 1's (so no model at all).  So far I found that when I go to reshape the data, that seems to be the breaking point for me.  I created a public notebook related to my findings.\n<a href=\"https://www.kaggle.com/yeayates21/cant-submit-1s-whats-wrong-please-help\">https://www.kaggle.com/yeayates21/cant-submit-1s-whats-wrong-please-help</a></p>",
      "rawMarkdown": "I think I came to the same conclusion that reshaping the parquet data causes submission to fail.  I've been having huge issues with this and I couldn't even submit 1's (so no model at all).  So far I found that when I go to reshape the data, that seems to be the breaking point for me.  I created a public notebook related to my findings.\nhttps://www.kaggle.com/yeayates21/cant-submit-1s-whats-wrong-please-help",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 722247,
      "author_name": "pestipeti",
      "author_url": "",
      "post_date": "01/18/2020 10:04:54",
      "content": "<p>This code is not optimized yet. You probably ran out of memory or time. Try a test commit with the train parquet files to see where is the issue. </p>\n\n<p>You can find my optimization tips <a href=\"https://www.kaggle.com/c/bengaliai-cv19/discussion/126054\">here</a>. (Implementation notebook included)</p>",
      "votes": null,
      "replies": [
        {
          "id": 722259,
          "author_name": "roguekk007",
          "author_url": "",
          "post_date": "01/18/2020 10:23:31",
          "content": "<p>Hi Peter, thanks for your answer! I was trying to keep the code minimal. It is probably not a timeout error I have received an explicit \"Notebook timeout error\" before. The \"Did not find CSV\" error is really confusing. I have read your optimization tips and found them very useful :)</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 723558,
          "author_name": "anirbank",
          "author_url": "",
          "post_date": "01/20/2020 06:42:05",
          "content": "<p>In order to avoid memory issues, i first saved the model as a h5 file. Now in my kernel i am loading this model making a prediction and submitting, even that results in Error, and no log is provided. Can someone help pls.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 722354,
      "author_name": "roguekk007",
      "author_url": "",
      "post_date": "01/18/2020 13:01:34",
      "content": "<p>There, I also managed to get a submission scoring error...I think I just obtained a collection of all make-able kaggle submission errors in my log now :)</p>",
      "votes": null,
      "replies": [
        {
          "id": 724963,
          "author_name": "ma7555",
          "author_url": "",
          "post_date": "01/21/2020 16:41:18",
          "content": "<p>it is really time consuming to debug uninformative errors like these given in the competition. we are data scientists not alchemists</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 725297,
          "author_name": "roguekk007",
          "author_url": "",
          "post_date": "01/22/2020 01:25:44",
          "content": "<p><a href=\"/ma7555\">@ma7555</a> My suggestion is that you start from an easy-to-understand successful inference kernel then change it to your own submission kernel step-by-step. I did this for 8 times and finally succeeded. In retrospect it was only 2 days, though (8 submissions).</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 722872,
      "author_name": "nroman",
      "author_url": "",
      "post_date": "01/19/2020 08:30:28",
      "content": "<p>This competition has two challenges. First of them is to make a submission :)</p>\n\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1696976%2F11388298dc71e325102614fd932723da%2F.png?generation=1579422596035225&amp;alt=media\" alt=\"\"></p>",
      "votes": null,
      "replies": [
        {
          "id": 723141,
          "author_name": "nroman",
          "author_url": "",
          "post_date": "01/19/2020 14:51:14",
          "content": "<p>There is no way to find out what exact exception was raised during submission. And I cannot reproduce it, since kernel's commit is successful. It would be really helpful to show the stack trace in this case, since there is no way to debug this issue.</p>\n\n<p><a href=\"/addisonhoward\">@addisonhoward</a> <a href=\"/sohier\">@sohier</a> </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 723428,
          "author_name": "roguekk007",
          "author_url": "",
          "post_date": "01/20/2020 02:52:31",
          "content": "<p>Exactly the same here! My commit kernel produces a valid submission but I got a \"submission CSV not found\" error. Debugging the submission process is really frustrating.\nLooking forward to solving this problem.\n<a href=\"/addisonhoward\">@addisonhoward</a> <a href=\"/sohier\">@sohier</a> </p>\n\n<p>Here is the tragic submission log for me\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1943421%2F8f9a6e3e0776692335d9660feb4f42cd%2Fsubmission_error.jpg?generation=1579488879291317&amp;alt=media\" alt=\"\"></p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 724318,
      "author_name": "roguekk007",
      "author_url": "",
      "post_date": "01/21/2020 03:21:22",
      "content": "<p>Hi! I solved my submission error by doing 9 controlled experiments (yes, I failed 8 times) and 29 previously failed submissions👋 . Seems like the first challenge in the competition is indeed making a successful submission :) Here is what worked for me, hope it helps.\n        I found that the crop_resize function (which I edited a little) and transformation led to failure. <strong>I added a backup transform without crop_resize with try:...except:... and solved the problem.</strong> Single model which achieves .972 CV leads to my current position.</p>\n\n<p>Original Code (fails)\n```\nclass GraphemeDataset(Dataset):\n    def <strong>init</strong>(self, fname, transform):\n        self.df = pd.read_parquet(fname)\n        self.data = 255 - self.df.iloc[:, 1:].values.reshape(-1, HEIGHT, WIDTH).astype(np.uint8)\n        self.transform = transform</p>\n\n<pre><code>def __len__(self):\n    return len(self.data)\n\ndef __getitem__(self, idx):\n    name = self.df.iloc[idx,0]\n    img = self.data[idx].astype(np.uint8)\n    img = self.transform(image=img)['image']\n    return img, name\n</code></pre>\n\n<p>```</p>\n\n<p>Successful Code\n```\nclass GraphemeDataset(Dataset):\n    def <strong>init</strong>(self, fname, transform):\n        self.df = pd.read_parquet(fname)\n        self.data = self.df.iloc[:, 1:].values.reshape(-1, HEIGHT, WIDTH).astype(np.uint8)\n        self.transform = transform</p>\n\n<pre><code>def __len__(self):\n    return len(self.data)\n\ndef __getitem__(self, idx):\n    name = self.df.iloc[idx,0]\n    try:\n        img = 255 - self.data[idx].astype(np.uint8)\n        img = self.transform(image=img)['image']\n    except:\n        img = 255 - self.data[idx].astype(np.uint8)\n        img = backup_tsfm(image=img)['image']\n    return img, name\n</code></pre>\n\n<p>```</p>\n\n<p>Still investigating why crop-resize fails, though. Any hypotheses?\nHere is the code for my crop-resize and transformation\n```\ndef bbox(img):\n    rows = np.any(img, axis=1)\n    cols = np.any(img, axis=0)\n    rmin, rmax = np.where(rows)[0][[0, -1]]\n    cmin, cmax = np.where(cols)[0][[0, -1]]\n    return rmin, rmax, cmin, cmax</p>\n\n<p>def crop_resize(img0, size=SIZE, pad=8, cols=None, rows=None, force_apply=False):\n    #crop a box around pixels large than the threshold \n    #some images contain line at the sides\n    ymin,ymax,xmin,xmax = bbox(img0[5:-5,5:-5] &gt; 80)\n    #cropping may cut too much, so we need to add it back\n    xmin = xmin - 13 if (xmin &gt; 13) else 0\n    ymin = ymin - 10 if (ymin &gt; 10) else 0\n    xmax = xmax + 13 if (xmax &lt; WIDTH - 13) else WIDTH\n    ymax = ymax + 10 if (ymax &lt; HEIGHT - 10) else HEIGHT\n    img = img0[ymin:ymax,xmin:xmax]\n    #remove lo intensity pixels as noise\n    img[img &lt; 28] = 0\n    lx, ly = xmax-xmin,ymax-ymin\n    l = max(lx,ly) + pad\n    #make sure that the aspect ratio is kept in rescaling\n    img = np.pad(img, [((l-ly)//2,), ((l-lx)//2,)], mode='constant')\n    return cv2.resize(img,(size,size))</p>\n\n<p>tsfm = Compose([\n                Lambda(image=crop_resize),\n                Resize(SIZE, SIZE),\n                Normalize((.0855,),(.2,)),\n                ToTensor(),\n            ])\n```</p>",
      "votes": null,
      "replies": [
        {
          "id": 727842,
          "author_name": "roshanpadaki",
          "author_url": "",
          "post_date": "01/24/2020 05:33:55",
          "content": "<p>I ran into this myself -- my best guess is there must be some blank or extremely faint image in the test set, which causes the indexing in <code>bbox</code> to fail, since both <code>rows</code> and <code>cols</code> would be empty. I seem to have solved this by adding simple checks in <code>bbox</code>. Again frustrating to fix, but that's what I get for copying over code without thinking hard enough :P</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 730084,
          "author_name": "ma7555",
          "author_url": "",
          "post_date": "01/27/2020 05:04:05",
          "content": "<p><a href=\"/roshanpadaki\">@roshanpadaki</a> but how could inference succeed here?\n<a href=\"https://www.kaggle.com/iafoss/grapheme-fast-ai-starter-inference\">https://www.kaggle.com/iafoss/grapheme-fast-ai-starter-inference</a></p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 730133,
          "author_name": "roguekk007",
          "author_url": "",
          "post_date": "01/27/2020 06:17:13",
          "content": "<p>I am wondering about the same thing, as fixing this problem could potentially help LB. Maybe because I changed some parameters? Did you change any? <a href=\"/roshanpadaki\">@roshanpadaki</a> </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 732689,
          "author_name": "kasim0226",
          "author_url": "",
          "post_date": "01/30/2020 05:38:22",
          "content": "<p>Could I know what you did on backup_tsfm?\nJust resize image and do data augmentation?\nLooking forward to your reply</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 744280,
          "author_name": "yeayates21",
          "author_url": "",
          "post_date": "02/12/2020 17:40:01",
          "content": "<p>I think I came to the same conclusion that reshaping the parquet data causes submission to fail.  I've been having huge issues with this and I couldn't even submit 1's (so no model at all).  So far I found that when I go to reshape the data, that seems to be the breaking point for me.  I created a public notebook related to my findings.\n<a href=\"https://www.kaggle.com/yeayates21/cant-submit-1s-whats-wrong-please-help\">https://www.kaggle.com/yeayates21/cant-submit-1s-whats-wrong-please-help</a></p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 725714,
      "author_name": "gaur128",
      "author_url": "",
      "post_date": "01/22/2020 12:28:19",
      "content": "<p>Same case for me as well but with an additional error. Not sure what I did wrong as commit only take about 400-500s.\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2116526%2Fc10a4c43fbda19be97406fd98a2b7c00%2FScreenshot%202020-01-21%20at%2012.38.23%20PM.png?generation=1579696072557804&amp;alt=media\" alt=\"\"></p>",
      "votes": null,
      "replies": [
        {
          "id": 744275,
          "author_name": "yeayates21",
          "author_url": "",
          "post_date": "02/12/2020 17:35:48",
          "content": "<p>I've been having huge issues with this and I couldn't even submit 1's.  So far I found that when I go to reshape the data, that seems to be the breaking point for me.  I created a public notebook related to my findings.\n<a href=\"https://www.kaggle.com/yeayates21/cant-submit-1s-whats-wrong-please-help\">https://www.kaggle.com/yeayates21/cant-submit-1s-whats-wrong-please-help</a></p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 728727,
      "author_name": "tiandaye",
      "author_url": "",
      "post_date": "01/25/2020 06:43:48",
      "content": "<p>welcome board.✌️ </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 735742,
      "author_name": "ma7555",
      "author_url": "",
      "post_date": "02/03/2020 12:10:07",
      "content": "<p><a href=\"/roguekk007\">@roguekk007</a> I think I understand now why his inference kernel works. simply because he normalized the image before calling the crop_resize so this fixed the <em>too faint image</em> problem...</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "722241": "Hi, everyone! Been struggling to make a successful submission. There are the timeouts, kaggle error, etc. So I decide to give the discussion a try.\n\nHere is a kernel I forked and edited. \nhttps://www.kaggle.com/roguekk007/another-stab\nThe resnet34 achieves .970 CV locally, but when running it I got **submission CSV not found**. I am running at 224x224 resolution which I found helps. \n\nCommiting the kernel gives me a submission.csv. Why is there this error?\nAny help is appreciated, thanks👍",
    "722247": "This code is not optimized yet. You probably ran out of memory or time. Try a test commit with the train parquet files to see where is the issue. \n\nYou can find my optimization tips [here](https://www.kaggle.com/c/bengaliai-cv19/discussion/126054). (Implementation notebook included)",
    "722259": "Hi Peter, thanks for your answer! I was trying to keep the code minimal. It is probably not a timeout error I have received an explicit \"Notebook timeout error\" before. The \"Did not find CSV\" error is really confusing. I have read your optimization tips and found them very useful :)",
    "722354": "There, I also managed to get a submission scoring error...I think I just obtained a collection of all make-able kaggle submission errors in my log now :)",
    "722872": "This competition has two challenges. First of them is to make a submission :)\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1696976%2F11388298dc71e325102614fd932723da%2F.png?generation=1579422596035225&amp;alt=media)",
    "723141": "There is no way to find out what exact exception was raised during submission. And I cannot reproduce it, since kernel's commit is successful. It would be really helpful to show the stack trace in this case, since there is no way to debug this issue.\n\n@addisonhoward @sohier",
    "723428": "Exactly the same here! My commit kernel produces a valid submission but I got a \"submission CSV not found\" error. Debugging the submission process is really frustrating.\nLooking forward to solving this problem.\n@addisonhoward @sohier \n\nHere is the tragic submission log for me\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1943421%2F8f9a6e3e0776692335d9660feb4f42cd%2Fsubmission_error.jpg?generation=1579488879291317&amp;alt=media)",
    "723558": "In order to avoid memory issues, i first saved the model as a h5 file. Now in my kernel i am loading this model making a prediction and submitting, even that results in Error, and no log is provided. Can someone help pls.",
    "724318": "Hi! I solved my submission error by doing 9 controlled experiments (yes, I failed 8 times) and 29 previously failed submissions👋 . Seems like the first challenge in the competition is indeed making a successful submission :) Here is what worked for me, hope it helps.\n        I found that the crop_resize function (which I edited a little) and transformation led to failure. **I added a backup transform without crop_resize with try:...except:... and solved the problem.** Single model which achieves .972 CV leads to my current position.\n\nOriginal Code (fails)\n```\nclass GraphemeDataset(Dataset):\n    def __init__(self, fname, transform):\n        self.df = pd.read_parquet(fname)\n        self.data = 255 - self.df.iloc[:, 1:].values.reshape(-1, HEIGHT, WIDTH).astype(np.uint8)\n        self.transform = transform\n\n    def __len__(self):\n        return len(self.data)\n\n    def __getitem__(self, idx):\n        name = self.df.iloc[idx,0]\n        img = self.data[idx].astype(np.uint8)\n        img = self.transform(image=img)['image']\n        return img, name\n```\n\nSuccessful Code\n```\nclass GraphemeDataset(Dataset):\n    def __init__(self, fname, transform):\n        self.df = pd.read_parquet(fname)\n        self.data = self.df.iloc[:, 1:].values.reshape(-1, HEIGHT, WIDTH).astype(np.uint8)\n        self.transform = transform\n\n    def __len__(self):\n        return len(self.data)\n\n    def __getitem__(self, idx):\n        name = self.df.iloc[idx,0]\n        try:\n            img = 255 - self.data[idx].astype(np.uint8)\n            img = self.transform(image=img)['image']\n        except:\n            img = 255 - self.data[idx].astype(np.uint8)\n            img = backup_tsfm(image=img)['image']\n        return img, name\n```\n\nStill investigating why crop-resize fails, though. Any hypotheses?\nHere is the code for my crop-resize and transformation\n```\ndef bbox(img):\n    rows = np.any(img, axis=1)\n    cols = np.any(img, axis=0)\n    rmin, rmax = np.where(rows)[0][[0, -1]]\n    cmin, cmax = np.where(cols)[0][[0, -1]]\n    return rmin, rmax, cmin, cmax\n\ndef crop_resize(img0, size=SIZE, pad=8, cols=None, rows=None, force_apply=False):\n    #crop a box around pixels large than the threshold \n    #some images contain line at the sides\n    ymin,ymax,xmin,xmax = bbox(img0[5:-5,5:-5] &gt; 80)\n    #cropping may cut too much, so we need to add it back\n    xmin = xmin - 13 if (xmin &gt; 13) else 0\n    ymin = ymin - 10 if (ymin &gt; 10) else 0\n    xmax = xmax + 13 if (xmax &lt; WIDTH - 13) else WIDTH\n    ymax = ymax + 10 if (ymax &lt; HEIGHT - 10) else HEIGHT\n    img = img0[ymin:ymax,xmin:xmax]\n    #remove lo intensity pixels as noise\n    img[img &lt; 28] = 0\n    lx, ly = xmax-xmin,ymax-ymin\n    l = max(lx,ly) + pad\n    #make sure that the aspect ratio is kept in rescaling\n    img = np.pad(img, [((l-ly)//2,), ((l-lx)//2,)], mode='constant')\n    return cv2.resize(img,(size,size))\n\ntsfm = Compose([\n                Lambda(image=crop_resize),\n                Resize(SIZE, SIZE),\n                Normalize((.0855,),(.2,)),\n                ToTensor(),\n            ])\n```",
    "724963": "it is really time consuming to debug uninformative errors like these given in the competition. we are data scientists not alchemists",
    "725297": "ma7555 My suggestion is that you start from an easy-to-understand successful inference kernel then change it to your own submission kernel step-by-step. I did this for 8 times and finally succeeded. In retrospect it was only 2 days, though (8 submissions).",
    "725714": "Same case for me as well but with an additional error. Not sure what I did wrong as commit only take about 400-500s.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2116526%2Fc10a4c43fbda19be97406fd98a2b7c00%2FScreenshot%202020-01-21%20at%2012.38.23%20PM.png?generation=1579696072557804&amp;alt=media)",
    "727842": "I ran into this myself -- my best guess is there must be some blank or extremely faint image in the test set, which causes the indexing in `bbox` to fail, since both `rows` and `cols` would be empty. I seem to have solved this by adding simple checks in `bbox`. Again frustrating to fix, but that's what I get for copying over code without thinking hard enough :P",
    "728727": "welcome board.✌️",
    "730084": "roshanpadaki but how could inference succeed here?\nhttps://www.kaggle.com/iafoss/grapheme-fast-ai-starter-inference",
    "730133": "I am wondering about the same thing, as fixing this problem could potentially help LB. Maybe because I changed some parameters? Did you change any? @roshanpadaki",
    "732689": "Could I know what you did on backup_tsfm?\nJust resize image and do data augmentation?\nLooking forward to your reply",
    "735742": "roguekk007 I think I understand now why his inference kernel works. simply because he normalized the image before calling the crop_resize so this fixed the *too faint image* problem...",
    "744275": "I've been having huge issues with this and I couldn't even submit 1's.  So far I found that when I go to reshape the data, that seems to be the breaking point for me.  I created a public notebook related to my findings.\nhttps://www.kaggle.com/yeayates21/cant-submit-1s-whats-wrong-please-help",
    "744280": "I think I came to the same conclusion that reshaping the parquet data causes submission to fail.  I've been having huge issues with this and I couldn't even submit 1's (so no model at all).  So far I found that when I go to reshape the data, that seems to be the breaking point for me.  I created a public notebook related to my findings.\nhttps://www.kaggle.com/yeayates21/cant-submit-1s-whats-wrong-please-help"
  },
  "source": "meta"
}