{
  "id": 150737,
  "title": "\"Notebook Threw Exception\" Error when submitting predictions",
  "url": "/competitions/prostate-cancer-grade-assessment/discussion/150737",
  "author_name": "Gaspar Avit",
  "post_date": "2020-05-13T08:14:36.305000",
  "votes": 1,
  "comment_count": 8,
  "views": 0,
  "content": "<p>I'm having a hard time submitting my predictions for this competition. My four last submissions resulted in the error \"Notebook Threw Exception\", which is not very informative.\nI have changed docker to \"Always use latest environment\" as I read in other discussion topics from Kaggle, but the result is the same. I have also tried submitting at different moments.\nWhen I commit my notebook it works just fine and saves the csv file which looks valid, but if I upload the output to the competition is when I get the error.\nThis is how I create my submission file (I fill the <code>isup_grade</code> column with my prediction, this is a dummy example):</p>\n\n<p>```\nif os.path.exists('../input/prostate-cancer-grade-assessment/test_images'):\n    submission = pd.read_csv('../input/prostate-cancer-grade-assessment/sample_submission.csv')\n    submission['isup_grade'] = np.array([3, 1, 0])\n    submission.to_csv('submission.csv',index=False)</p>\n\n<p>else:\n    print(\"Train only. Saving sample submission\")\n    submission = pd.read_csv('../input/prostate-cancer-grade-assessment/sample_submission.csv')\n    submission['isup_grade'] = np.array([0, 1, 0])\n    submission.to_csv('submission.csv',index=False)\n```</p>\n\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1375016%2F7146145e86b851e78415fb36057fcdfd%2FCaptura.PNG?generation=1589357655961599&amp;alt=media\" alt=\"\"></p>\n\n<p>Any help would be much appreciated.</p>",
  "messages": [
    {
      "id": 846792,
      "postDate": "2020-05-14T02:09:47.890Z",
      "content": "<p>Verify with the training data that your notebook is correct. Just swap the test dir for the train dir and the test csv for train csv and verify your notebook runs smoothly. </p>",
      "rawMarkdown": "Verify with the training data that your notebook is correct. Just swap the test dir for the train dir and the test csv for train csv and verify your notebook runs smoothly. ",
      "votes": 1,
      "replies": [
        {
          "id": 847229,
          "postDate": "2020-05-14T08:40:39.270Z",
          "content": "<p>It works perfectly fine when I run it with training data, as you can see the submission.csv is created. The way I load the test data is this:</p>\n\n<p><code>\nif os.path.exists('../input/prostate-cancer-grade-assessment/test_images'):\n    test_df = pd.read_csv('../input/prostate-cancer-grade-assessment/test.csv')\n    X_test = np.empty((test_df.shape[0], 256, 256, 3), dtype=np.float)\n    for i, image_id in enumerate(test_df['image_id']):\n        X_test[i, :, :, :] = preprocess_image(f'../input/prostate-cancer-grade-assessment/test_images/{image_id}.tiff', im_size) <br>\n</code></p>\n\n<p>Tell me if I'm doing something wrong, but I don't think so.</p>",
          "rawMarkdown": "It works perfectly fine when I run it with training data, as you can see the submission.csv is created. The way I load the test data is this:\n    \n```\nif os.path.exists('../input/prostate-cancer-grade-assessment/test_images'):\n    test_df = pd.read_csv('../input/prostate-cancer-grade-assessment/test.csv')\n    X_test = np.empty((test_df.shape[0], 256, 256, 3), dtype=np.float)\n    for i, image_id in enumerate(test_df['image_id']):\n        X_test[i, :, :, :] = preprocess_image(f'../input/prostate-cancer-grade-assessment/test_images/{image_id}.tiff', im_size)  \n```\n\nTell me if I'm doing something wrong, but I don't think so."
        },
        {
          "id": 848449,
          "postDate": "2020-05-15T01:24:00.630Z",
          "content": "<p>Well the submission.csv isn't proof as this is the sample. </p>\n\n<p>Did you actually try to swap your two first lines \nif os.path.exists('../input/prostate-cancer-grade-assessment/test_images'):\n    test_df = pd.read_csv('../input/prostate-cancer-grade-assessment/test.csv')\nwith\nif os.path.exists('../input/prostate-cancer-grade-assessment/train_images'):\n    test_df = pd.read_csv('../input/prostate-cancer-grade-assessment/train.csv')</p>\n\n<p>and run in the notebook (not commit) and verify it produces a file for the trainset.</p>",
          "rawMarkdown": "Well the submission.csv isn't proof as this is the sample. \n\nDid you actually try to swap your two first lines \nif os.path.exists('../input/prostate-cancer-grade-assessment/test_images'):\n    test_df = pd.read_csv('../input/prostate-cancer-grade-assessment/test.csv')\nwith\nif os.path.exists('../input/prostate-cancer-grade-assessment/train_images'):\n    test_df = pd.read_csv('../input/prostate-cancer-grade-assessment/train.csv')\n\nand run in the notebook (not commit) and verify it produces a file for the trainset."
        },
        {
          "id": 854892,
          "postDate": "2020-05-20T12:19:22.137Z",
          "content": "<p>I have tried what you suggest and it produces an output for the trainset as expected.\nI have created a very easy example to know if I'm able to read the <code>test_images</code> folder when committing, take a look if you can (<a href=\"https://www.kaggle.com/gasparavit/panda-submission-test\">https://www.kaggle.com/gasparavit/panda-submission-test</a> ). If I commit this simple script I get the mentioned <strong>Notebook Threw Exception</strong>.</p>",
          "rawMarkdown": "I have tried what you suggest and it produces an output for the trainset as expected.\nI have created a very easy example to know if I'm able to read the `test_images` folder when committing, take a look if you can (https://www.kaggle.com/gasparavit/panda-submission-test ). If I commit this simple script I get the mentioned **Notebook Threw Exception**."
        },
        {
          "id": 854931,
          "postDate": "2020-05-20T13:02:07.730Z",
          "content": "<p><a href=\"/gasparavit\">@gasparavit</a> Is internet enabled in your submission kernel?</p>",
          "rawMarkdown": "@gasparavit Is internet enabled in your submission kernel?"
        },
        {
          "id": 855066,
          "postDate": "2020-05-20T14:54:11.727Z",
          "content": "<p>No, internet is off.</p>",
          "rawMarkdown": "No, internet is off."
        }
      ]
    },
    {
      "id": 845532,
      "postDate": "2020-05-13T09:07:28.600Z",
      "content": "<p>Did you try running it with the training set? You might uncover what's happening.</p>",
      "rawMarkdown": "Did you try running it with the training set? You might uncover what's happening.",
      "votes": 1,
      "replies": [
        {
          "id": 854893,
          "postDate": "2020-05-20T12:21:25.423Z",
          "content": "<p>With the trainning set it works fine. The problem happens when reading the <code>test_images</code> folder.</p>",
          "rawMarkdown": "With the trainning set it works fine. The problem happens when reading the `test_images ` folder."
        }
      ]
    },
    {
      "id": 845472,
      "postDate": "2020-05-13T08:14:36.307Z",
      "content": "<p>I'm having a hard time submitting my predictions for this competition. My four last submissions resulted in the error \"Notebook Threw Exception\", which is not very informative.\nI have changed docker to \"Always use latest environment\" as I read in other discussion topics from Kaggle, but the result is the same. I have also tried submitting at different moments.\nWhen I commit my notebook it works just fine and saves the csv file which looks valid, but if I upload the output to the competition is when I get the error.\nThis is how I create my submission file (I fill the <code>isup_grade</code> column with my prediction, this is a dummy example):</p>\n\n<p>```\nif os.path.exists('../input/prostate-cancer-grade-assessment/test_images'):\n    submission = pd.read_csv('../input/prostate-cancer-grade-assessment/sample_submission.csv')\n    submission['isup_grade'] = np.array([3, 1, 0])\n    submission.to_csv('submission.csv',index=False)</p>\n\n<p>else:\n    print(\"Train only. Saving sample submission\")\n    submission = pd.read_csv('../input/prostate-cancer-grade-assessment/sample_submission.csv')\n    submission['isup_grade'] = np.array([0, 1, 0])\n    submission.to_csv('submission.csv',index=False)\n```</p>\n\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1375016%2F7146145e86b851e78415fb36057fcdfd%2FCaptura.PNG?generation=1589357655961599&amp;alt=media\" alt=\"\"></p>\n\n<p>Any help would be much appreciated.</p>",
      "rawMarkdown": "I'm having a hard time submitting my predictions for this competition. My four last submissions resulted in the error \"Notebook Threw Exception\", which is not very informative.\nI have changed docker to \"Always use latest environment\" as I read in other discussion topics from Kaggle, but the result is the same. I have also tried submitting at different moments.\nWhen I commit my notebook it works just fine and saves the csv file which looks valid, but if I upload the output to the competition is when I get the error.\nThis is how I create my submission file (I fill the `isup_grade` column with my prediction, this is a dummy example):\n\n```\nif os.path.exists('../input/prostate-cancer-grade-assessment/test_images'):\n    submission = pd.read_csv('../input/prostate-cancer-grade-assessment/sample_submission.csv')\n    submission['isup_grade'] = np.array([3, 1, 0])\n    submission.to_csv('submission.csv',index=False)\n\nelse:\n    print(\"Train only. Saving sample submission\")\n    submission = pd.read_csv('../input/prostate-cancer-grade-assessment/sample_submission.csv')\n    submission['isup_grade'] = np.array([0, 1, 0])\n    submission.to_csv('submission.csv',index=False)\n```\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1375016%2F7146145e86b851e78415fb36057fcdfd%2FCaptura.PNG?generation=1589357655961599&amp;alt=media)\n\nAny help would be much appreciated.",
      "votes": 1
    }
  ],
  "comments": [
    {
      "id": 846792,
      "author_name": "Arnaud Roussel",
      "author_url": "",
      "post_date": "2020-05-14T02:09:47.890000",
      "content": "<p>Verify with the training data that your notebook is correct. Just swap the test dir for the train dir and the test csv for train csv and verify your notebook runs smoothly. </p>",
      "votes": 1,
      "replies": [
        {
          "id": 847229,
          "author_name": "Gaspar Avit",
          "author_url": "",
          "post_date": "2020-05-14T08:40:39.270000",
          "content": "<p>It works perfectly fine when I run it with training data, as you can see the submission.csv is created. The way I load the test data is this:</p>\n\n<p><code>\nif os.path.exists('../input/prostate-cancer-grade-assessment/test_images'):\n    test_df = pd.read_csv('../input/prostate-cancer-grade-assessment/test.csv')\n    X_test = np.empty((test_df.shape[0], 256, 256, 3), dtype=np.float)\n    for i, image_id in enumerate(test_df['image_id']):\n        X_test[i, :, :, :] = preprocess_image(f'../input/prostate-cancer-grade-assessment/test_images/{image_id}.tiff', im_size) <br>\n</code></p>\n\n<p>Tell me if I'm doing something wrong, but I don't think so.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 848449,
          "author_name": "Arnaud Roussel",
          "author_url": "",
          "post_date": "2020-05-15T01:24:00.630000",
          "content": "<p>Well the submission.csv isn't proof as this is the sample. </p>\n\n<p>Did you actually try to swap your two first lines \nif os.path.exists('../input/prostate-cancer-grade-assessment/test_images'):\n    test_df = pd.read_csv('../input/prostate-cancer-grade-assessment/test.csv')\nwith\nif os.path.exists('../input/prostate-cancer-grade-assessment/train_images'):\n    test_df = pd.read_csv('../input/prostate-cancer-grade-assessment/train.csv')</p>\n\n<p>and run in the notebook (not commit) and verify it produces a file for the trainset.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 854892,
          "author_name": "Gaspar Avit",
          "author_url": "",
          "post_date": "2020-05-20T12:19:22.137000",
          "content": "<p>I have tried what you suggest and it produces an output for the trainset as expected.\nI have created a very easy example to know if I'm able to read the <code>test_images</code> folder when committing, take a look if you can (<a href=\"https://www.kaggle.com/gasparavit/panda-submission-test\">https://www.kaggle.com/gasparavit/panda-submission-test</a> ). If I commit this simple script I get the mentioned <strong>Notebook Threw Exception</strong>.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 854931,
          "author_name": "Yovin Yahathugoda",
          "author_url": "",
          "post_date": "2020-05-20T13:02:07.730000",
          "content": "<p><a href=\"/gasparavit\">@gasparavit</a> Is internet enabled in your submission kernel?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 855066,
          "author_name": "Gaspar Avit",
          "author_url": "",
          "post_date": "2020-05-20T14:54:11.727000",
          "content": "<p>No, internet is off.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 845532,
      "author_name": "Son of Anton v3.0",
      "author_url": "",
      "post_date": "2020-05-13T09:07:28.600000",
      "content": "<p>Did you try running it with the training set? You might uncover what's happening.</p>",
      "votes": 1,
      "replies": [
        {
          "id": 854893,
          "author_name": "Gaspar Avit",
          "author_url": "",
          "post_date": "2020-05-20T12:21:25.423000",
          "content": "<p>With the trainning set it works fine. The problem happens when reading the <code>test_images</code> folder.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "846792": "Verify with the training data that your notebook is correct. Just swap the test dir for the train dir and the test csv for train csv and verify your notebook runs smoothly. ",
    "845532": "Did you try running it with the training set? You might uncover what's happening.",
    "845472": "I'm having a hard time submitting my predictions for this competition. My four last submissions resulted in the error \"Notebook Threw Exception\", which is not very informative.\nI have changed docker to \"Always use latest environment\" as I read in other discussion topics from Kaggle, but the result is the same. I have also tried submitting at different moments.\nWhen I commit my notebook it works just fine and saves the csv file which looks valid, but if I upload the output to the competition is when I get the error.\nThis is how I create my submission file (I fill the `isup_grade` column with my prediction, this is a dummy example):\n\n```\nif os.path.exists('../input/prostate-cancer-grade-assessment/test_images'):\n    submission = pd.read_csv('../input/prostate-cancer-grade-assessment/sample_submission.csv')\n    submission['isup_grade'] = np.array([3, 1, 0])\n    submission.to_csv('submission.csv',index=False)\n\nelse:\n    print(\"Train only. Saving sample submission\")\n    submission = pd.read_csv('../input/prostate-cancer-grade-assessment/sample_submission.csv')\n    submission['isup_grade'] = np.array([0, 1, 0])\n    submission.to_csv('submission.csv',index=False)\n```\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F1375016%2F7146145e86b851e78415fb36057fcdfd%2FCaptura.PNG?generation=1589357655961599&amp;alt=media)\n\nAny help would be much appreciated."
  }
}