{
  "id": 198747,
  "title": "Can I use locally trained models?",
  "url": "/competitions/cassava-leaf-disease-classification/discussion/198747",
  "author_name": "",
  "post_date": "2020-11-22T21:14:23.310234100Z",
  "votes": 6,
  "comment_count": 10,
  "views": 0,
  "content": "<p>I would like to upload the model I trained locally on my machine rather than use the kernel to train it.</p>\n<p>Is that allowed? If so, how do I do it?</p>",
  "messages": [
    {
      "id": "1087561",
      "postDate": "11/22/2020 21:14:23",
      "content": "<p>I would like to upload the model I trained locally on my machine rather than use the kernel to train it.</p>\n<p>Is that allowed? If so, how do I do it?</p>",
      "rawMarkdown": "I would like to upload the model I trained locally on my machine rather than use the kernel to train it.\n\nIs that allowed? If so, how do I do it?",
      "votes": null
    },
    {
      "id": "1087599",
      "postDate": "11/22/2020 22:26:39",
      "content": "<p>Hey Rajat,</p>\n<p>Yes, you are allowed to do that. First create an inference kernel and upload your trained model as dataset. Then, use your model to predict the test images so you can generate the submission.csv. After committing your work successfully, click on \"My Submissions\" and submit your notebook.</p>",
      "rawMarkdown": "Hey Rajat,\n\nYes, you are allowed to do that. First create an inference kernel and upload your trained model as dataset. Then, use your model to predict the test images so you can generate the submission.csv. After committing your work successfully, click on \"My Submissions\" and submit your notebook.",
      "votes": null
    },
    {
      "id": "1087643",
      "postDate": "11/23/2020 00:15:29",
      "content": "<p>Yes, feel free to do so. Save the model after you trained and upload it as the dataset. Create the submission notebook, load the model, predict and submit.</p>",
      "rawMarkdown": "Yes, feel free to do so. Save the model after you trained and upload it as the dataset. Create the submission notebook, load the model, predict and submit.",
      "votes": null
    },
    {
      "id": "1087889",
      "postDate": "11/23/2020 06:18:10",
      "content": "<p>import tensorflow as tf<br>\nimport numpy as np<br>\nimport os<br>\nimport pandas as pd<br>\nfrom keras.engine.saving import save_model<br>\nfrom keras.preprocessing import image<br>\nmodel=tf.keras.models.load_model('../input/training-den169/leaf1.h5')<br>\nimport glob<br>\ntest = os.listdir('/kaggle/input/cassava-leaf-disease-classification/test_images/')<br>\nfor img in glob.glob(\"../input/cassava-leaf-disease-classification/test_images/*.jpg\"):<br>\nimg_predicitions=image.load_img(img,target_size=(224,224,3))<br>\nimg_predicition=image.img_to_array(img_predicitions)<br>\nimg_predicition=np.expand_dims(img_predicition,axis=0)</p>\n<pre><code>result=model.predict_classes(img_predicition)\n\nprint(img, result)\nsubmission = pd.DataFrame({'image_id': test, 'label': result})\nsubmission.to_csv('submission.csv', index=False )\nprint(submission)\n</code></pre>",
      "rawMarkdown": "import tensorflow as tf\nimport numpy as np\nimport os\nimport pandas as pd\nfrom keras.engine.saving import save_model\nfrom keras.preprocessing import image\nmodel=tf.keras.models.load_model('../input/training-den169/leaf1.h5')\nimport glob\ntest = os.listdir('/kaggle/input/cassava-leaf-disease-classification/test_images/')\nfor img in glob.glob(\"../input/cassava-leaf-disease-classification/test_images/*.jpg\"):\nimg_predicitions=image.load_img(img,target_size=(224,224,3))\nimg_predicition=image.img_to_array(img_predicitions)\nimg_predicition=np.expand_dims(img_predicition,axis=0)\n\n    result=model.predict_classes(img_predicition)\n\n    print(img, result)\n    submission = pd.DataFrame({'image_id': test, 'label': result})\n    submission.to_csv('submission.csv', index=False )\n    print(submission)",
      "votes": null
    },
    {
      "id": "1087892",
      "postDate": "11/23/2020 06:19:02",
      "content": "<p>i am facing problem. when i submit it says submission.csv not found, any help?</p>",
      "rawMarkdown": "i am facing problem. when i submit it says submission.csv not found, any help?",
      "votes": null
    },
    {
      "id": "1088802",
      "postDate": "11/24/2020 00:31:44",
      "content": "<p>I had the same question but per the rules:</p>\n<ul>\n<li>CPU Notebook &lt;= 9 hours run-time</li>\n<li>GPU Notebook &lt;= 9 hours run-time</li>\n<li>TPUs will not be available for making submissions to this competition. You are still welcome to use them for training models. A walk-through for how to train on TPUs and run inference/submit on GPUs, see our TPU Docs.</li>\n<li>Internet access disabled</li>\n<li>Freely &amp; publicly available external data is allowed, including pre-trained models</li>\n<li>Submission file must be named \"submission.csv\"</li>\n</ul>\n<p>Do custom trained model weights that I put in the dataset count as external data. If so they must be publicly available? Maybe I'm overthinking this but the rules aren't clear here. If I have custom model + custom weights that I load into my script submission is that allowed if they reside within a private dataset?</p>",
      "rawMarkdown": "I had the same question but per the rules:\n\n- CPU Notebook <= 9 hours run-time\n- GPU Notebook <= 9 hours run-time\n- TPUs will not be available for making submissions to this competition. You are still welcome to use them for training models. A walk-through for how to train on TPUs and run inference/submit on GPUs, see our TPU Docs.\n- Internet access disabled\n- Freely & publicly available external data is allowed, including pre-trained models\n- Submission file must be named \"submission.csv\"\n\nDo custom trained model weights that I put in the dataset count as external data. If so they must be publicly available? Maybe I'm overthinking this but the rules aren't clear here. If I have custom model + custom weights that I load into my script submission is that allowed if they reside within a private dataset?",
      "votes": null
    },
    {
      "id": "1088815",
      "postDate": "11/24/2020 00:50:57",
      "content": "<p>Models you design and your model weights don't count as external data.</p>\n<p>If you used some pre-built/pre-trained models and weights as a starting point, those are external data. But not models/weights you create yourself.</p>\n<p>I'm not sure if there is still a requirement to \"declare\" external data. External data must be freely available, but I think the requirement to disclose it before the competition deadline is not in this contest.</p>\n<p>From the rules:</p>\n<p>C. External Data. You may use data other than the Competition Data (“External Data”) to develop and test your Submissions. However, you will ensure the External Data is publicly available to use by all participants of the Competition for purposes of the competition at no cost to the other participants. The ability to use External Data under this Section 7.C (External Data) does not limit you other obligations under these Competition Rules, including but not limited to Section 11 (Winners Obligations).</p>\n<p>-Rich</p>",
      "rawMarkdown": "Models you design and your model weights don't count as external data.\n\nIf you used some pre-built/pre-trained models and weights as a starting point, those are external data. But not models/weights you create yourself.\n\nI'm not sure if there is still a requirement to \"declare\" external data. External data must be freely available, but I think the requirement to disclose it before the competition deadline is not in this contest.\n\nFrom the rules:\n\nC. External Data. You may use data other than the Competition Data (“External Data”) to develop and test your Submissions. However, you will ensure the External Data is publicly available to use by all participants of the Competition for purposes of the competition at no cost to the other participants. The ability to use External Data under this Section 7.C (External Data) does not limit you other obligations under these Competition Rules, including but not limited to Section 11 (Winners Obligations).\n\n-Rich",
      "votes": null
    },
    {
      "id": "1090551",
      "postDate": "11/25/2020 12:17:54",
      "content": "<p><a href=\"https://www.kaggle.com/aeryss\" target=\"_blank\">@aeryss</a> , I followed the same approach but my public score shows zero..any reason for that ?</p>",
      "rawMarkdown": "aeryss , I followed the same approach but my public score shows zero..any reason for that ?",
      "votes": null
    },
    {
      "id": "1090610",
      "postDate": "11/25/2020 13:29:16",
      "content": "<p>Probably you make the wrong submission format. For safely, insert any image into the test set and make predictions to see if it is in the same format.</p>",
      "rawMarkdown": "Probably you make the wrong submission format. For safely, insert any image into the test set and make predictions to see if it is in the same format.",
      "votes": null
    },
    {
      "id": "1091526",
      "postDate": "11/26/2020 04:56:59",
      "content": "<p>It is resolved, I made a small mistake in code which was caught only when I ran with multiple test images… thanks for the help</p>",
      "rawMarkdown": "It is resolved, I made a small mistake in code which was caught only when I ran with multiple test images... thanks for the help",
      "votes": null
    },
    {
      "id": "1099474",
      "postDate": "12/02/2020 11:45:01",
      "content": "<p>I faced similar issue, competition is tested on multiple test images on a private dataset, while we are supplied with only 1 test image, to understand the actual issue in the code, replace test images with train images batches and check the issue…..</p>",
      "rawMarkdown": "I faced similar issue, competition is tested on multiple test images on a private dataset, while we are supplied with only 1 test image, to understand the actual issue in the code, replace test images with train images batches and check the issue.....",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1087599,
      "author_name": "socratis",
      "author_url": "",
      "post_date": "11/22/2020 22:26:39",
      "content": "<p>Hey Rajat,</p>\n<p>Yes, you are allowed to do that. First create an inference kernel and upload your trained model as dataset. Then, use your model to predict the test images so you can generate the submission.csv. After committing your work successfully, click on \"My Submissions\" and submit your notebook.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1087889,
          "author_name": "mtalhaarshad",
          "author_url": "",
          "post_date": "11/23/2020 06:18:10",
          "content": "<p>import tensorflow as tf<br>\nimport numpy as np<br>\nimport os<br>\nimport pandas as pd<br>\nfrom keras.engine.saving import save_model<br>\nfrom keras.preprocessing import image<br>\nmodel=tf.keras.models.load_model('../input/training-den169/leaf1.h5')<br>\nimport glob<br>\ntest = os.listdir('/kaggle/input/cassava-leaf-disease-classification/test_images/')<br>\nfor img in glob.glob(\"../input/cassava-leaf-disease-classification/test_images/*.jpg\"):<br>\nimg_predicitions=image.load_img(img,target_size=(224,224,3))<br>\nimg_predicition=image.img_to_array(img_predicitions)<br>\nimg_predicition=np.expand_dims(img_predicition,axis=0)</p>\n<pre><code>result=model.predict_classes(img_predicition)\n\nprint(img, result)\nsubmission = pd.DataFrame({'image_id': test, 'label': result})\nsubmission.to_csv('submission.csv', index=False )\nprint(submission)\n</code></pre>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1087892,
          "author_name": "mtalhaarshad",
          "author_url": "",
          "post_date": "11/23/2020 06:19:02",
          "content": "<p>i am facing problem. when i submit it says submission.csv not found, any help?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1099474,
          "author_name": "anukool89",
          "author_url": "",
          "post_date": "12/02/2020 11:45:01",
          "content": "<p>I faced similar issue, competition is tested on multiple test images on a private dataset, while we are supplied with only 1 test image, to understand the actual issue in the code, replace test images with train images batches and check the issue…..</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1087643,
      "author_name": "aeryss",
      "author_url": "",
      "post_date": "11/23/2020 00:15:29",
      "content": "<p>Yes, feel free to do so. Save the model after you trained and upload it as the dataset. Create the submission notebook, load the model, predict and submit.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1088802,
      "author_name": "ajcostarino",
      "author_url": "",
      "post_date": "11/24/2020 00:31:44",
      "content": "<p>I had the same question but per the rules:</p>\n<ul>\n<li>CPU Notebook &lt;= 9 hours run-time</li>\n<li>GPU Notebook &lt;= 9 hours run-time</li>\n<li>TPUs will not be available for making submissions to this competition. You are still welcome to use them for training models. A walk-through for how to train on TPUs and run inference/submit on GPUs, see our TPU Docs.</li>\n<li>Internet access disabled</li>\n<li>Freely &amp; publicly available external data is allowed, including pre-trained models</li>\n<li>Submission file must be named \"submission.csv\"</li>\n</ul>\n<p>Do custom trained model weights that I put in the dataset count as external data. If so they must be publicly available? Maybe I'm overthinking this but the rules aren't clear here. If I have custom model + custom weights that I load into my script submission is that allowed if they reside within a private dataset?</p>",
      "votes": null,
      "replies": [
        {
          "id": 1088815,
          "author_name": "richardepstein",
          "author_url": "",
          "post_date": "11/24/2020 00:50:57",
          "content": "<p>Models you design and your model weights don't count as external data.</p>\n<p>If you used some pre-built/pre-trained models and weights as a starting point, those are external data. But not models/weights you create yourself.</p>\n<p>I'm not sure if there is still a requirement to \"declare\" external data. External data must be freely available, but I think the requirement to disclose it before the competition deadline is not in this contest.</p>\n<p>From the rules:</p>\n<p>C. External Data. You may use data other than the Competition Data (“External Data”) to develop and test your Submissions. However, you will ensure the External Data is publicly available to use by all participants of the Competition for purposes of the competition at no cost to the other participants. The ability to use External Data under this Section 7.C (External Data) does not limit you other obligations under these Competition Rules, including but not limited to Section 11 (Winners Obligations).</p>\n<p>-Rich</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1090551,
      "author_name": "anukool89",
      "author_url": "",
      "post_date": "11/25/2020 12:17:54",
      "content": "<p><a href=\"https://www.kaggle.com/aeryss\" target=\"_blank\">@aeryss</a> , I followed the same approach but my public score shows zero..any reason for that ?</p>",
      "votes": null,
      "replies": [
        {
          "id": 1090610,
          "author_name": "aeryss",
          "author_url": "",
          "post_date": "11/25/2020 13:29:16",
          "content": "<p>Probably you make the wrong submission format. For safely, insert any image into the test set and make predictions to see if it is in the same format.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1091526,
          "author_name": "anukool89",
          "author_url": "",
          "post_date": "11/26/2020 04:56:59",
          "content": "<p>It is resolved, I made a small mistake in code which was caught only when I ran with multiple test images… thanks for the help</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1087561": "I would like to upload the model I trained locally on my machine rather than use the kernel to train it.\n\nIs that allowed? If so, how do I do it?",
    "1087599": "Hey Rajat,\n\nYes, you are allowed to do that. First create an inference kernel and upload your trained model as dataset. Then, use your model to predict the test images so you can generate the submission.csv. After committing your work successfully, click on \"My Submissions\" and submit your notebook.",
    "1087643": "Yes, feel free to do so. Save the model after you trained and upload it as the dataset. Create the submission notebook, load the model, predict and submit.",
    "1087889": "import tensorflow as tf\nimport numpy as np\nimport os\nimport pandas as pd\nfrom keras.engine.saving import save_model\nfrom keras.preprocessing import image\nmodel=tf.keras.models.load_model('../input/training-den169/leaf1.h5')\nimport glob\ntest = os.listdir('/kaggle/input/cassava-leaf-disease-classification/test_images/')\nfor img in glob.glob(\"../input/cassava-leaf-disease-classification/test_images/*.jpg\"):\nimg_predicitions=image.load_img(img,target_size=(224,224,3))\nimg_predicition=image.img_to_array(img_predicitions)\nimg_predicition=np.expand_dims(img_predicition,axis=0)\n\n    result=model.predict_classes(img_predicition)\n\n    print(img, result)\n    submission = pd.DataFrame({'image_id': test, 'label': result})\n    submission.to_csv('submission.csv', index=False )\n    print(submission)",
    "1087892": "i am facing problem. when i submit it says submission.csv not found, any help?",
    "1088802": "I had the same question but per the rules:\n\n- CPU Notebook <= 9 hours run-time\n- GPU Notebook <= 9 hours run-time\n- TPUs will not be available for making submissions to this competition. You are still welcome to use them for training models. A walk-through for how to train on TPUs and run inference/submit on GPUs, see our TPU Docs.\n- Internet access disabled\n- Freely & publicly available external data is allowed, including pre-trained models\n- Submission file must be named \"submission.csv\"\n\nDo custom trained model weights that I put in the dataset count as external data. If so they must be publicly available? Maybe I'm overthinking this but the rules aren't clear here. If I have custom model + custom weights that I load into my script submission is that allowed if they reside within a private dataset?",
    "1088815": "Models you design and your model weights don't count as external data.\n\nIf you used some pre-built/pre-trained models and weights as a starting point, those are external data. But not models/weights you create yourself.\n\nI'm not sure if there is still a requirement to \"declare\" external data. External data must be freely available, but I think the requirement to disclose it before the competition deadline is not in this contest.\n\nFrom the rules:\n\nC. External Data. You may use data other than the Competition Data (“External Data”) to develop and test your Submissions. However, you will ensure the External Data is publicly available to use by all participants of the Competition for purposes of the competition at no cost to the other participants. The ability to use External Data under this Section 7.C (External Data) does not limit you other obligations under these Competition Rules, including but not limited to Section 11 (Winners Obligations).\n\n-Rich",
    "1090551": "aeryss , I followed the same approach but my public score shows zero..any reason for that ?",
    "1090610": "Probably you make the wrong submission format. For safely, insert any image into the test set and make predictions to see if it is in the same format.",
    "1091526": "It is resolved, I made a small mistake in code which was caught only when I ran with multiple test images... thanks for the help",
    "1099474": "I faced similar issue, competition is tested on multiple test images on a private dataset, while we are supplied with only 1 test image, to understand the actual issue in the code, replace test images with train images batches and check the issue....."
  },
  "source": "meta"
}