{
  "id": 447851,
  "title": "On submitting notebook to competition, getting Notebook Threw Exception",
  "url": "/competitions/UBC-OCEAN/discussion/447851",
  "author_name": "Balmukund",
  "post_date": "2023-10-17T13:26:40.181000",
  "votes": 2,
  "comment_count": 2,
  "views": 0,
  "content": "<p>On submitting notebook to competition, getting Notebook Threw Exception.<br>\nBasically i am making inference to the test images from test_thumbnail folder, the code runs fine but on submitting the notebook it is throwing exception. Any help is appreciated as i am stuck here.</p>\n<p><code>currentFolder = data_path + 'test_thumbnails'</code><br>\n<code>preds = []</code><br>\n<code>ids = []</code><br>\n<code>try:</code><br>\n<code>for i, file in enumerate(os.listdir(currentFolder)[0:10]):</code><br>\n<code>if '_' in file:</code><br>\n<code>id = file.split(\"_\")[0]</code><br>\n<code>else:</code><br>\n<code>continue</code><br>\n<code>ids.append(id)</code><br>\n<code>img = Image.open(currentFolder+\"/\"+file).convert('RGB')</code><br>\n<code>image_tensor = test_transform(img)</code><br>\n<code>image_tensor.unsqueeze_(0)</code><br>\n<code>output = model(image_tensor.to(device))</code><br>\n<code>index = output.cpu().data.numpy().argmax()</code><br>\n<code>pred = rev_class_map[index]</code><br>\n<code>preds.append(pred)</code><br>\n<code>except:</code><br>\n<code>pass</code></p>",
  "messages": [
    {
      "id": 2485834,
      "postDate": "2023-10-17T13:40:46.600Z",
      "content": "<p>Might be the <code>[0:10]</code> which is only taking the first 10 images, and will cause problems while submitting </p>",
      "rawMarkdown": "Might be the `[0:10]` which is only taking the first 10 images, and will cause problems while submitting ",
      "votes": 2,
      "replies": [
        {
          "id": 2485922,
          "postDate": "2023-10-17T14:31:01.043Z",
          "content": "<p>I added to test for first 10 images later to see if at all it goes to the next level of scoring the notebook but it failed with same error.</p>",
          "rawMarkdown": "I added to test for first 10 images later to see if at all it goes to the next level of scoring the notebook but it failed with same error."
        }
      ]
    },
    {
      "id": 2485818,
      "postDate": "2023-10-17T13:26:40.180Z",
      "content": "<p>On submitting notebook to competition, getting Notebook Threw Exception.<br>\nBasically i am making inference to the test images from test_thumbnail folder, the code runs fine but on submitting the notebook it is throwing exception. Any help is appreciated as i am stuck here.</p>\n<p><code>currentFolder = data_path + 'test_thumbnails'</code><br>\n<code>preds = []</code><br>\n<code>ids = []</code><br>\n<code>try:</code><br>\n<code>for i, file in enumerate(os.listdir(currentFolder)[0:10]):</code><br>\n<code>if '_' in file:</code><br>\n<code>id = file.split(\"_\")[0]</code><br>\n<code>else:</code><br>\n<code>continue</code><br>\n<code>ids.append(id)</code><br>\n<code>img = Image.open(currentFolder+\"/\"+file).convert('RGB')</code><br>\n<code>image_tensor = test_transform(img)</code><br>\n<code>image_tensor.unsqueeze_(0)</code><br>\n<code>output = model(image_tensor.to(device))</code><br>\n<code>index = output.cpu().data.numpy().argmax()</code><br>\n<code>pred = rev_class_map[index]</code><br>\n<code>preds.append(pred)</code><br>\n<code>except:</code><br>\n<code>pass</code></p>",
      "rawMarkdown": "On submitting notebook to competition, getting Notebook Threw Exception.\nBasically i am making inference to the test images from test_thumbnail folder, the code runs fine but on submitting the notebook it is throwing exception. Any help is appreciated as i am stuck here.\n\n`currentFolder = data_path + 'test_thumbnails'`\n`preds = []`\n`ids = []`\n`try:`\n`    for i, file in enumerate(os.listdir(currentFolder)[0:10]):`\n`        if '_' in file:`\n`            id = file.split(\"_\")[0]`\n`        else:`\n`            continue`\n`        ids.append(id)`\n`        img = Image.open(currentFolder+\"/\"+file).convert('RGB')`\n`        image_tensor = test_transform(img)`\n`        image_tensor.unsqueeze_(0)`\n`        output = model(image_tensor.to(device))`\n`        index = output.cpu().data.numpy().argmax()`\n`        pred = rev_class_map[index]`\n`        preds.append(pred)`\n`except:`\n`    pass`",
      "votes": 2
    }
  ],
  "comments": [
    {
      "id": 2485834,
      "author_name": "pjmathematician",
      "author_url": "",
      "post_date": "2023-10-17T13:40:46.600000",
      "content": "<p>Might be the <code>[0:10]</code> which is only taking the first 10 images, and will cause problems while submitting </p>",
      "votes": 2,
      "replies": [
        {
          "id": 2485922,
          "author_name": "Balmukund",
          "author_url": "",
          "post_date": "2023-10-17T14:31:01.043000",
          "content": "<p>I added to test for first 10 images later to see if at all it goes to the next level of scoring the notebook but it failed with same error.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2485834": "Might be the `[0:10]` which is only taking the first 10 images, and will cause problems while submitting ",
    "2485818": "On submitting notebook to competition, getting Notebook Threw Exception.\nBasically i am making inference to the test images from test_thumbnail folder, the code runs fine but on submitting the notebook it is throwing exception. Any help is appreciated as i am stuck here.\n\n`currentFolder = data_path + 'test_thumbnails'`\n`preds = []`\n`ids = []`\n`try:`\n`    for i, file in enumerate(os.listdir(currentFolder)[0:10]):`\n`        if '_' in file:`\n`            id = file.split(\"_\")[0]`\n`        else:`\n`            continue`\n`        ids.append(id)`\n`        img = Image.open(currentFolder+\"/\"+file).convert('RGB')`\n`        image_tensor = test_transform(img)`\n`        image_tensor.unsqueeze_(0)`\n`        output = model(image_tensor.to(device))`\n`        index = output.cpu().data.numpy().argmax()`\n`        pred = rev_class_map[index]`\n`        preds.append(pred)`\n`except:`\n`    pass`"
  }
}