{
  "id": 206273,
  "title": "Always getting Submission CSV Not Found Error. Need Help!",
  "url": "/competitions/cassava-leaf-disease-classification/discussion/206273",
  "author_name": "",
  "post_date": "2020-12-23T19:49:26.997113Z",
  "votes": 1,
  "comment_count": 6,
  "views": 0,
  "content": "<p>I am trying to make a submission but I always get submission csv not found error. I create the file and my code run without errors when I run all.<br>\nHere is the codes that I use to create the submission file:</p>\n<hr>\n<p>from PIL import Image</p>\n<p>test_imgs_folder = '../input/cassava-leaf-disease-classification/test_images/'<br>\ntest_csv = '../input/cassava-leaf-disease-classification/sample_submission.csv'<br>\nsubmission = pd.read_csv(test_csv)  # Read the sample_submission.csv.</p>\n<p>preds = []</p>\n<p>for img in submission['image_id']:<br>\n    pred = os.path.join(test_imgs_folder, img)<br>\n    pred = Image.open(pred)<br>\n    pred = pred.resize(IMAGE_SIZE)<br>\n    pred = np.array(pred)<br>\n    pred = np.expand_dims(pred, axis=0)<br>\n    preds.append(model.predict(pred).argmax(axis = 1)[0])</p>\n<p>submission['label'] = preds  <br>\nsubmission.to_csv('submission.csv', index=False)</p>\n<hr>\n<p>Thank you.</p>",
  "messages": [
    {
      "id": "1124290",
      "postDate": "12/23/2020 19:49:26",
      "content": "<p>I am trying to make a submission but I always get submission csv not found error. I create the file and my code run without errors when I run all.<br>\nHere is the codes that I use to create the submission file:</p>\n<hr>\n<p>from PIL import Image</p>\n<p>test_imgs_folder = '../input/cassava-leaf-disease-classification/test_images/'<br>\ntest_csv = '../input/cassava-leaf-disease-classification/sample_submission.csv'<br>\nsubmission = pd.read_csv(test_csv)  # Read the sample_submission.csv.</p>\n<p>preds = []</p>\n<p>for img in submission['image_id']:<br>\n    pred = os.path.join(test_imgs_folder, img)<br>\n    pred = Image.open(pred)<br>\n    pred = pred.resize(IMAGE_SIZE)<br>\n    pred = np.array(pred)<br>\n    pred = np.expand_dims(pred, axis=0)<br>\n    preds.append(model.predict(pred).argmax(axis = 1)[0])</p>\n<p>submission['label'] = preds  <br>\nsubmission.to_csv('submission.csv', index=False)</p>\n<hr>\n<p>Thank you.</p>",
      "rawMarkdown": "I am trying to make a submission but I always get submission csv not found error. I create the file and my code run without errors when I run all.\nHere is the codes that I use to create the submission file:\n\n-----------------------------------------------\n\nfrom PIL import Image\n\ntest_imgs_folder = '../input/cassava-leaf-disease-classification/test_images/'\ntest_csv = '../input/cassava-leaf-disease-classification/sample_submission.csv'\nsubmission = pd.read_csv(test_csv)  # Read the sample_submission.csv.\n\npreds = []\n\nfor img in submission['image_id']:\n    pred = os.path.join(test_imgs_folder, img)\n    pred = Image.open(pred)\n    pred = pred.resize(IMAGE_SIZE)\n    pred = np.array(pred)\n    pred = np.expand_dims(pred, axis=0)\n    preds.append(model.predict(pred).argmax(axis = 1)[0])\n\nsubmission['label'] = preds  \nsubmission.to_csv('submission.csv', index=False)\n\n-----------------------------------------------\n\nThank you.",
      "votes": null
    },
    {
      "id": "1125623",
      "postDate": "12/24/2020 21:53:24",
      "content": "<p>I'm also having the same issue with this competition! This is really anoying. Localy everything works. In the kaggle notebook i generated some test images to see if my submission file looks well. But nothing worked for now…<br>\nI now have the impression that its not possible to use the test_images folder when making a submission. Can anyone confirm that?</p>",
      "rawMarkdown": "I'm also having the same issue with this competition! This is really anoying. Localy everything works. In the kaggle notebook i generated some test images to see if my submission file looks well. But nothing worked for now...\nI now have the impression that its not possible to use the test_images folder when making a submission. Can anyone confirm that?",
      "votes": null
    },
    {
      "id": "1125716",
      "postDate": "12/25/2020 02:16:12",
      "content": "<p>The input folders in past competitions have been \"read only\" - I assume that is also the case here but have not confirmed.  Not sure what you mean by \"not possible\" but if your code writes to the test_images folder than I believe it will fail.</p>",
      "rawMarkdown": "The input folders in past competitions have been \"read only\" - I assume that is also the case here but have not confirmed.  Not sure what you mean by \"not possible\" but if your code writes to the test_images folder than I believe it will fail.",
      "votes": null
    },
    {
      "id": "1126125",
      "postDate": "12/25/2020 11:15:40",
      "content": "<p>there is only one test image in the test folder so no need to use for loop you can directly took that test image and predict the class. try following code,<br>\nimport cv2<br>\ntest_img = cv2.imread('../input/cassava-leaf-disease-classification/test_images/2216849948.jpg')<br>\ntest_img = cv2.resize(test_img,(150,150)) #put the size of image accoding to your input_shape in first layer <br>\ntest_img = np.reshape(test_img,[1,150,150,3])<br>\nlabel = model.predict(test_img)<br>\nlabel=np.argmax(label)<br>\nsub['label']=label<br>\nsub.to_csv('submission.csv',index=False)</p>",
      "rawMarkdown": "there is only one test image in the test folder so no need to use for loop you can directly took that test image and predict the class. try following code,\nimport cv2\ntest_img = cv2.imread('../input/cassava-leaf-disease-classification/test_images/2216849948.jpg')\ntest_img = cv2.resize(test_img,(150,150)) #put the size of image accoding to your input_shape in first layer \ntest_img = np.reshape(test_img,[1,150,150,3])\nlabel = model.predict(test_img)\nlabel=np.argmax(label)\nsub['label']=label\nsub.to_csv('submission.csv',index=False)",
      "votes": null
    },
    {
      "id": "1126136",
      "postDate": "12/25/2020 11:26:08",
      "content": "<p>Thanks for the answer. I'm not copying anything to the input folder but to my working path (\"/kaggle/working/\"). I wanted to use the ImageDataGenerator from Keras which requires to have an additional folder using its flow_from_directory method.  I now found another post of you in the Deepfake Challenge in which you stated that it might not be allowed to copy more than 500 files to that path? Do you think that is also true for this competition? </p>",
      "rawMarkdown": "Thanks for the answer. I'm not copying anything to the input folder but to my working path (\"/kaggle/working/\"). I wanted to use the ImageDataGenerator from Keras which requires to have an additional folder using its flow_from_directory method.  I now found another post of you in the Deepfake Challenge in which you stated that it might not be allowed to copy more than 500 files to that path? Do you think that is also true for this competition?",
      "votes": null
    },
    {
      "id": "1126681",
      "postDate": "12/25/2020 20:02:28",
      "content": "<p>Do not recall all the details of the Deepfake post (at 74 my memory RAM is getting shaky)  - think I had learned of the limit from someone else's post.  As I recall I had to save only the current batch of images to avoid the error.  Have no idea if an upper limit on files exists for this competition - still doing all my inference on my local machines.</p>\n<p>Think I also had another work-around on my todo list but never tried it.  Was going to create a folder full of blank images of the right size - add that set of files as a dataset and than save my modifications into that set of folders.</p>",
      "rawMarkdown": "Do not recall all the details of the Deepfake post (at 74 my memory RAM is getting shaky)  - think I had learned of the limit from someone else's post.  As I recall I had to save only the current batch of images to avoid the error.  Have no idea if an upper limit on files exists for this competition - still doing all my inference on my local machines.\n\nThink I also had another work-around on my todo list but never tried it.  Was going to create a folder full of blank images of the right size - add that set of files as a dataset and than save my modifications into that set of folders.",
      "votes": null
    },
    {
      "id": "1126685",
      "postDate": "12/25/2020 20:08:29",
      "content": "<p>The private test file will contain 15K of images - so reading only one will not work - you need some type of iteration.</p>",
      "rawMarkdown": "The private test file will contain 15K of images - so reading only one will not work - you need some type of iteration.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1125623,
      "author_name": "jannish",
      "author_url": "",
      "post_date": "12/24/2020 21:53:24",
      "content": "<p>I'm also having the same issue with this competition! This is really anoying. Localy everything works. In the kaggle notebook i generated some test images to see if my submission file looks well. But nothing worked for now…<br>\nI now have the impression that its not possible to use the test_images folder when making a submission. Can anyone confirm that?</p>",
      "votes": null,
      "replies": [
        {
          "id": 1125716,
          "author_name": "pcjimmmy",
          "author_url": "",
          "post_date": "12/25/2020 02:16:12",
          "content": "<p>The input folders in past competitions have been \"read only\" - I assume that is also the case here but have not confirmed.  Not sure what you mean by \"not possible\" but if your code writes to the test_images folder than I believe it will fail.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1126136,
          "author_name": "jannish",
          "author_url": "",
          "post_date": "12/25/2020 11:26:08",
          "content": "<p>Thanks for the answer. I'm not copying anything to the input folder but to my working path (\"/kaggle/working/\"). I wanted to use the ImageDataGenerator from Keras which requires to have an additional folder using its flow_from_directory method.  I now found another post of you in the Deepfake Challenge in which you stated that it might not be allowed to copy more than 500 files to that path? Do you think that is also true for this competition? </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1126681,
          "author_name": "pcjimmmy",
          "author_url": "",
          "post_date": "12/25/2020 20:02:28",
          "content": "<p>Do not recall all the details of the Deepfake post (at 74 my memory RAM is getting shaky)  - think I had learned of the limit from someone else's post.  As I recall I had to save only the current batch of images to avoid the error.  Have no idea if an upper limit on files exists for this competition - still doing all my inference on my local machines.</p>\n<p>Think I also had another work-around on my todo list but never tried it.  Was going to create a folder full of blank images of the right size - add that set of files as a dataset and than save my modifications into that set of folders.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1126125,
      "author_name": "kamleshshimpi78",
      "author_url": "",
      "post_date": "12/25/2020 11:15:40",
      "content": "<p>there is only one test image in the test folder so no need to use for loop you can directly took that test image and predict the class. try following code,<br>\nimport cv2<br>\ntest_img = cv2.imread('../input/cassava-leaf-disease-classification/test_images/2216849948.jpg')<br>\ntest_img = cv2.resize(test_img,(150,150)) #put the size of image accoding to your input_shape in first layer <br>\ntest_img = np.reshape(test_img,[1,150,150,3])<br>\nlabel = model.predict(test_img)<br>\nlabel=np.argmax(label)<br>\nsub['label']=label<br>\nsub.to_csv('submission.csv',index=False)</p>",
      "votes": null,
      "replies": [
        {
          "id": 1126685,
          "author_name": "pcjimmmy",
          "author_url": "",
          "post_date": "12/25/2020 20:08:29",
          "content": "<p>The private test file will contain 15K of images - so reading only one will not work - you need some type of iteration.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1124290": "I am trying to make a submission but I always get submission csv not found error. I create the file and my code run without errors when I run all.\nHere is the codes that I use to create the submission file:\n\n-----------------------------------------------\n\nfrom PIL import Image\n\ntest_imgs_folder = '../input/cassava-leaf-disease-classification/test_images/'\ntest_csv = '../input/cassava-leaf-disease-classification/sample_submission.csv'\nsubmission = pd.read_csv(test_csv)  # Read the sample_submission.csv.\n\npreds = []\n\nfor img in submission['image_id']:\n    pred = os.path.join(test_imgs_folder, img)\n    pred = Image.open(pred)\n    pred = pred.resize(IMAGE_SIZE)\n    pred = np.array(pred)\n    pred = np.expand_dims(pred, axis=0)\n    preds.append(model.predict(pred).argmax(axis = 1)[0])\n\nsubmission['label'] = preds  \nsubmission.to_csv('submission.csv', index=False)\n\n-----------------------------------------------\n\nThank you.",
    "1125623": "I'm also having the same issue with this competition! This is really anoying. Localy everything works. In the kaggle notebook i generated some test images to see if my submission file looks well. But nothing worked for now...\nI now have the impression that its not possible to use the test_images folder when making a submission. Can anyone confirm that?",
    "1125716": "The input folders in past competitions have been \"read only\" - I assume that is also the case here but have not confirmed.  Not sure what you mean by \"not possible\" but if your code writes to the test_images folder than I believe it will fail.",
    "1126125": "there is only one test image in the test folder so no need to use for loop you can directly took that test image and predict the class. try following code,\nimport cv2\ntest_img = cv2.imread('../input/cassava-leaf-disease-classification/test_images/2216849948.jpg')\ntest_img = cv2.resize(test_img,(150,150)) #put the size of image accoding to your input_shape in first layer \ntest_img = np.reshape(test_img,[1,150,150,3])\nlabel = model.predict(test_img)\nlabel=np.argmax(label)\nsub['label']=label\nsub.to_csv('submission.csv',index=False)",
    "1126136": "Thanks for the answer. I'm not copying anything to the input folder but to my working path (\"/kaggle/working/\"). I wanted to use the ImageDataGenerator from Keras which requires to have an additional folder using its flow_from_directory method.  I now found another post of you in the Deepfake Challenge in which you stated that it might not be allowed to copy more than 500 files to that path? Do you think that is also true for this competition?",
    "1126681": "Do not recall all the details of the Deepfake post (at 74 my memory RAM is getting shaky)  - think I had learned of the limit from someone else's post.  As I recall I had to save only the current batch of images to avoid the error.  Have no idea if an upper limit on files exists for this competition - still doing all my inference on my local machines.\n\nThink I also had another work-around on my todo list but never tried it.  Was going to create a folder full of blank images of the right size - add that set of files as a dataset and than save my modifications into that set of folders.",
    "1126685": "The private test file will contain 15K of images - so reading only one will not work - you need some type of iteration."
  },
  "source": "meta"
}