{
  "id": 461098,
  "title": "[Submission] Help with Notebook Threw Exception. Struggling to find the root cause.",
  "url": "/competitions/UBC-OCEAN/discussion/461098",
  "author_name": "Aaditya Nanduri",
  "post_date": "2023-12-12T17:07:35.442000",
  "votes": 1,
  "comment_count": 1,
  "views": 0,
  "content": "<p>Hi All, I would love any guidance on resolving the <strong>Notebook Threw Exception</strong> issue I'm facing. </p>\n<p>The code is running fine on the public dataset (training and the single test image). To resolve this, I have:</p>\n<ol>\n<li>Reviewed my code 3-4 times for errors (no pip-installs, correctly linking data sources, ensuring successful model load, etc.)</li>\n<li>Confirmed that the images URLs are being determined appropriately</li>\n<li>Removed all image manipulation (except resizing)</li>\n</ol>\n<p>None of these have resolved the problem.</p>\n<p>Below is the code from the latest submission. I simply tried to label all test images as <strong>HGSC</strong> and still, it threw up a <strong>Notebook Threw Exception</strong>.</p>\n<p>Any advice would be helpful!</p>\n<p>Please see my code below. I have commented sections as my latest attempt was labeling all records the same (HGSC).</p>\n<pre><code> logging\n fastai.vision.  *\n pandas  pd\n numpy  np\n os\n sys\nsys.path.append()\n common_code  *\n\nlogger = logging.getLogger(__name__)\nhandler = logging.StreamHandler()\nhandler.setLevel(logging.INFO)\nlogger.addHandler(handler)\n\nlogger.info()\n\nlearn = load_learner()\nlogger.info()\n\n\ndf_test = pd.read_csv()\nlogger.info()\ndf_test.head()\n\ndf_test[] = \ndf_test.head()\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\ndf_test[[, ]].to_csv(, index=)\nlogger.info()\n</code></pre>",
  "messages": [
    {
      "id": 2559231,
      "postDate": "2023-12-12T17:07:35.443Z",
      "content": "<p>Hi All, I would love any guidance on resolving the <strong>Notebook Threw Exception</strong> issue I'm facing. </p>\n<p>The code is running fine on the public dataset (training and the single test image). To resolve this, I have:</p>\n<ol>\n<li>Reviewed my code 3-4 times for errors (no pip-installs, correctly linking data sources, ensuring successful model load, etc.)</li>\n<li>Confirmed that the images URLs are being determined appropriately</li>\n<li>Removed all image manipulation (except resizing)</li>\n</ol>\n<p>None of these have resolved the problem.</p>\n<p>Below is the code from the latest submission. I simply tried to label all test images as <strong>HGSC</strong> and still, it threw up a <strong>Notebook Threw Exception</strong>.</p>\n<p>Any advice would be helpful!</p>\n<p>Please see my code below. I have commented sections as my latest attempt was labeling all records the same (HGSC).</p>\n<pre><code> logging\n fastai.vision.  *\n pandas  pd\n numpy  np\n os\n sys\nsys.path.append()\n common_code  *\n\nlogger = logging.getLogger(__name__)\nhandler = logging.StreamHandler()\nhandler.setLevel(logging.INFO)\nlogger.addHandler(handler)\n\nlogger.info()\n\nlearn = load_learner()\nlogger.info()\n\n\ndf_test = pd.read_csv()\nlogger.info()\ndf_test.head()\n\ndf_test[] = \ndf_test.head()\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\ndf_test[[, ]].to_csv(, index=)\nlogger.info()\n</code></pre>",
      "rawMarkdown": "Hi All, I would love any guidance on resolving the **Notebook Threw Exception** issue I'm facing. \n\nThe code is running fine on the public dataset (training and the single test image). To resolve this, I have:\n\n1. Reviewed my code 3-4 times for errors (no pip-installs, correctly linking data sources, ensuring successful model load, etc.)\n2. Confirmed that the images URLs are being determined appropriately\n3. Removed all image manipulation (except resizing)\n\nNone of these have resolved the problem.\n\nBelow is the code from the latest submission. I simply tried to label all test images as **HGSC** and still, it threw up a **Notebook Threw Exception**.\n\nAny advice would be helpful!\n\nPlease see my code below. I have commented sections as my latest attempt was labeling all records the same (HGSC).\n\n\n```python\nimport logging\nfrom fastai.vision.all import *\nimport pandas as pd\nimport numpy as np\nimport os\nimport sys\nsys.path.append('/kaggle/input/ubc-ocean')\nfrom common_code import *\n\nlogger = logging.getLogger(__name__)\nhandler = logging.StreamHandler()\nhandler.setLevel(logging.INFO)\nlogger.addHandler(handler)\n\nlogger.info('Packages loaded. Common code loaded.')\n\nlearn = load_learner('/kaggle/input/ubc-ocean/model.pkl')\nlogger.info('Model loaded')\n\n# df_test = pd.read_csv(config.df_test)\ndf_test = pd.read_csv('/kaggle/input/UBC-OCEAN/test.csv')\nlogger.info(f'Test data loaded. Shape : {df_test.shape}')\ndf_test.head()\n\ndf_test['label'] = 'HGSC'\ndf_test.head()\n\n# def imageURLs(row):\n#     if row['image_height'] > 5000:\n#         return os.path.join(config.img_testt, str(row['image_id']) + '_thumbnail.png')\n#     else:\n#         return os.path.join(config.img_test, str(row['image_id'] + '.png'))\n\n# df_test['image_url'] = df_test.apply(imageURLs, axis = 1)\n# df_test.head()\n# logger.info('Test data image URLs determined.')\n\n# def applyPred(row):\n#     label,_,probs = learn.predict(PILImage.create(row['image_url']))\n#     if probs[np.argmax(probs)] <= 0.5:\n#         label = 'Other'\n    \n#     pos = np.argmax(probs)\n#     probs = probs.detach().numpy()[pos]\n    \n#     logger.info(f\"The label for image #{row['image_id']} is {label}({probs:0.3f})\")\n#     return pd.Series((label, probs, dls.vocab[pos]))\n    \n# df_test[['label', 'probability', 'label_check']] = df_test.apply(applyPred, axis = 1)\n\n\ndf_test[['image_id', 'label']].to_csv('submission.csv', index=False)\nlogger.info(f'Submission file created. Shape {df_test[[\"image_id\", \"label\"]].shape}')\n```",
      "votes": 1
    },
    {
      "id": 2561323,
      "postDate": "2023-12-14T12:13:36.650Z",
      "content": "<p>it is hard to track, I suggested to a similar question, you can run this notebook on whole train data to be able to see and track down the error</p>",
      "rawMarkdown": "it is hard to track, I suggested to a similar question, you can run this notebook on whole train data to be able to see and track down the error",
      "votes": 2
    }
  ],
  "comments": [
    {
      "id": 2561323,
      "author_name": "Ali",
      "author_url": "",
      "post_date": "2023-12-14T12:13:36.650000",
      "content": "<p>it is hard to track, I suggested to a similar question, you can run this notebook on whole train data to be able to see and track down the error</p>",
      "votes": 2,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2559231": "Hi All, I would love any guidance on resolving the **Notebook Threw Exception** issue I'm facing. \n\nThe code is running fine on the public dataset (training and the single test image). To resolve this, I have:\n\n1. Reviewed my code 3-4 times for errors (no pip-installs, correctly linking data sources, ensuring successful model load, etc.)\n2. Confirmed that the images URLs are being determined appropriately\n3. Removed all image manipulation (except resizing)\n\nNone of these have resolved the problem.\n\nBelow is the code from the latest submission. I simply tried to label all test images as **HGSC** and still, it threw up a **Notebook Threw Exception**.\n\nAny advice would be helpful!\n\nPlease see my code below. I have commented sections as my latest attempt was labeling all records the same (HGSC).\n\n\n```python\nimport logging\nfrom fastai.vision.all import *\nimport pandas as pd\nimport numpy as np\nimport os\nimport sys\nsys.path.append('/kaggle/input/ubc-ocean')\nfrom common_code import *\n\nlogger = logging.getLogger(__name__)\nhandler = logging.StreamHandler()\nhandler.setLevel(logging.INFO)\nlogger.addHandler(handler)\n\nlogger.info('Packages loaded. Common code loaded.')\n\nlearn = load_learner('/kaggle/input/ubc-ocean/model.pkl')\nlogger.info('Model loaded')\n\n# df_test = pd.read_csv(config.df_test)\ndf_test = pd.read_csv('/kaggle/input/UBC-OCEAN/test.csv')\nlogger.info(f'Test data loaded. Shape : {df_test.shape}')\ndf_test.head()\n\ndf_test['label'] = 'HGSC'\ndf_test.head()\n\n# def imageURLs(row):\n#     if row['image_height'] > 5000:\n#         return os.path.join(config.img_testt, str(row['image_id']) + '_thumbnail.png')\n#     else:\n#         return os.path.join(config.img_test, str(row['image_id'] + '.png'))\n\n# df_test['image_url'] = df_test.apply(imageURLs, axis = 1)\n# df_test.head()\n# logger.info('Test data image URLs determined.')\n\n# def applyPred(row):\n#     label,_,probs = learn.predict(PILImage.create(row['image_url']))\n#     if probs[np.argmax(probs)] <= 0.5:\n#         label = 'Other'\n    \n#     pos = np.argmax(probs)\n#     probs = probs.detach().numpy()[pos]\n    \n#     logger.info(f\"The label for image #{row['image_id']} is {label}({probs:0.3f})\")\n#     return pd.Series((label, probs, dls.vocab[pos]))\n    \n# df_test[['label', 'probability', 'label_check']] = df_test.apply(applyPred, axis = 1)\n\n\ndf_test[['image_id', 'label']].to_csv('submission.csv', index=False)\nlogger.info(f'Submission file created. Shape {df_test[[\"image_id\", \"label\"]].shape}')\n```",
    "2561323": "it is hard to track, I suggested to a similar question, you can run this notebook on whole train data to be able to see and track down the error"
  }
}