{
  "id": 201570,
  "title": "Basic question: how to use pretrained models?",
  "url": "/competitions/cassava-leaf-disease-classification/discussion/201570",
  "author_name": "",
  "post_date": "2020-12-05T16:11:22.202857900Z",
  "votes": 5,
  "comment_count": 11,
  "views": 0,
  "content": "<p>I feel extremely silly asking this, but how do we use pretrained models with internet access disabled?</p>\n<p>I am trying to use models simply from <code>torchvision.models</code>, they attempt to download them from the internet, and then it fails. </p>",
  "messages": [
    {
      "id": "1103087",
      "postDate": "12/05/2020 16:11:22",
      "content": "<p>I feel extremely silly asking this, but how do we use pretrained models with internet access disabled?</p>\n<p>I am trying to use models simply from <code>torchvision.models</code>, they attempt to download them from the internet, and then it fails. </p>",
      "rawMarkdown": "I feel extremely silly asking this, but how do we use pretrained models with internet access disabled?\n\nI am trying to use models simply from `torchvision.models`, they attempt to download them from the internet, and then it fails.",
      "votes": null
    },
    {
      "id": "1103104",
      "postDate": "12/05/2020 16:32:09",
      "content": "<p>You can create public or private dataset and import that dataset in your notebook , so now you can easily access those pretrained models in your code.</p>\n<p>Hope this helped.</p>",
      "rawMarkdown": "You can create public or private dataset and import that dataset in your notebook , so now you can easily access those pretrained models in your code.\n\nHope this helped.",
      "votes": null
    },
    {
      "id": "1103215",
      "postDate": "12/05/2020 18:17:09",
      "content": "<p>Thanks, this helps!</p>",
      "rawMarkdown": "Thanks, this helps!",
      "votes": null
    },
    {
      "id": "1103293",
      "postDate": "12/05/2020 19:47:21",
      "content": "<p>In fact, for something as popular as torchivision models, someone had probably already done it. It's the same for any popular packages that Kaggle happens to not include in their package selection. You'll find examples of the necessary sys.path.append(…) code in lots of public notebooks.</p>",
      "rawMarkdown": "In fact, for something as popular as torchivision models, someone had probably already done it. It's the same for any popular packages that Kaggle happens to not include in their package selection. You'll find examples of the necessary sys.path.append(...) code in lots of public notebooks.",
      "votes": null
    },
    {
      "id": "1104345",
      "postDate": "12/06/2020 20:42:26",
      "content": "<p>You can train in a notebook with the internet on and later load the trained model in a notebook exclusively for inference. The inference notebook would have the internet off.</p>",
      "rawMarkdown": "You can train in a notebook with the internet on and later load the trained model in a notebook exclusively for inference. The inference notebook would have the internet off.",
      "votes": null
    },
    {
      "id": "1104734",
      "postDate": "12/07/2020 07:34:55",
      "content": "<p>How can this be done? I sensed this should be possible, but couldn't figure out how. Every time I try to submit, it says that I need to have internet off. So I turn it off, then \"save and run all\", it tries to run the whole notebook from scratch with internet off and fails.</p>",
      "rawMarkdown": "How can this be done? I sensed this should be possible, but couldn't figure out how. Every time I try to submit, it says that I need to have internet off. So I turn it off, then \"save and run all\", it tries to run the whole notebook from scratch with internet off and fails.",
      "votes": null
    },
    {
      "id": "1104793",
      "postDate": "12/07/2020 08:19:36",
      "content": "<p>You create two separate notebooks. One keeps the internet on and does the training of the model. In the second one, you switch the internet off and pick your other notebook as an input under \"Add data\". An example of this set-up is <a href=\"https://www.kaggle.com/abhishek/leaf-disease-inference-using-tez\" target=\"_blank\">this inference notebook</a>, or this pair that makes it very transparent: <a href=\"https://www.kaggle.com/muellerzr/recreating-abhishek-s-tez-with-fastai\" target=\"_blank\">training notebook</a> + <a href=\"https://www.kaggle.com/muellerzr/fastai-abhishek-inference\" target=\"_blank\">inference notebook</a>.</p>",
      "rawMarkdown": "You create two separate notebooks. One keeps the internet on and does the training of the model. In the second one, you switch the internet off and pick your other notebook as an input under \"Add data\". An example of this set-up is [this inference notebook](https://www.kaggle.com/abhishek/leaf-disease-inference-using-tez), or this pair that makes it very transparent: [training notebook](https://www.kaggle.com/muellerzr/recreating-abhishek-s-tez-with-fastai) + [inference notebook](https://www.kaggle.com/muellerzr/fastai-abhishek-inference).",
      "votes": null
    },
    {
      "id": "1104993",
      "postDate": "12/07/2020 12:49:37",
      "content": "<p>Here i created a notebook to demonstrate how to train with the internet on: <a href=\"https://www.kaggle.com/epochs19/superbeginner-training-notebook\" target=\"_blank\">https://www.kaggle.com/epochs19/superbeginner-training-notebook</a>  <br>\nHope this helps</p>",
      "rawMarkdown": "Here i created a notebook to demonstrate how to train with the internet on: https://www.kaggle.com/epochs19/superbeginner-training-notebook  \nHope this helps",
      "votes": null
    },
    {
      "id": "1105192",
      "postDate": "12/07/2020 15:50:41",
      "content": "<p>Great, thank you!</p>",
      "rawMarkdown": "Great, thank you!",
      "votes": null
    },
    {
      "id": "1105292",
      "postDate": "12/07/2020 18:25:26",
      "content": "<p>Hi! You can add your dataset with your pretrained models and add it to your notebook as an external source of data. Checkpoints can be accessed then as <code>/kaggle/input/NAME_OF_DATASET/your_model.pth</code></p>",
      "rawMarkdown": "Hi! You can add your dataset with your pretrained models and add it to your notebook as an external source of data. Checkpoints can be accessed then as `/kaggle/input/NAME_OF_DATASET/your_model.pth`",
      "votes": null
    },
    {
      "id": "1199834",
      "postDate": "02/14/2021 06:17:16",
      "content": "<p>I had same question,and could solve too!! It was very helpful!!<br>\nThank you!!</p>",
      "rawMarkdown": "I had same question,and could solve too!! It was very helpful!!\nThank you!!",
      "votes": null
    },
    {
      "id": "1200671",
      "postDate": "02/14/2021 21:12:01",
      "content": "<p>You can refer the 2 notebooks for training and inference <a href=\"https://www.kaggle.com/c/cassava-leaf-disease-classification/discussion/216461\" target=\"_blank\">here</a></p>",
      "rawMarkdown": "You can refer the 2 notebooks for training and inference [here](https://www.kaggle.com/c/cassava-leaf-disease-classification/discussion/216461)",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1103104,
      "author_name": "prashantarorat",
      "author_url": "",
      "post_date": "12/05/2020 16:32:09",
      "content": "<p>You can create public or private dataset and import that dataset in your notebook , so now you can easily access those pretrained models in your code.</p>\n<p>Hope this helped.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1103215,
          "author_name": "btseytlin",
          "author_url": "",
          "post_date": "12/05/2020 18:17:09",
          "content": "<p>Thanks, this helps!</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1103293,
          "author_name": "bjoernholzhauer",
          "author_url": "",
          "post_date": "12/05/2020 19:47:21",
          "content": "<p>In fact, for something as popular as torchivision models, someone had probably already done it. It's the same for any popular packages that Kaggle happens to not include in their package selection. You'll find examples of the necessary sys.path.append(…) code in lots of public notebooks.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1104345,
      "author_name": "epochs19",
      "author_url": "",
      "post_date": "12/06/2020 20:42:26",
      "content": "<p>You can train in a notebook with the internet on and later load the trained model in a notebook exclusively for inference. The inference notebook would have the internet off.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1104734,
          "author_name": "btseytlin",
          "author_url": "",
          "post_date": "12/07/2020 07:34:55",
          "content": "<p>How can this be done? I sensed this should be possible, but couldn't figure out how. Every time I try to submit, it says that I need to have internet off. So I turn it off, then \"save and run all\", it tries to run the whole notebook from scratch with internet off and fails.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1104793,
          "author_name": "bjoernholzhauer",
          "author_url": "",
          "post_date": "12/07/2020 08:19:36",
          "content": "<p>You create two separate notebooks. One keeps the internet on and does the training of the model. In the second one, you switch the internet off and pick your other notebook as an input under \"Add data\". An example of this set-up is <a href=\"https://www.kaggle.com/abhishek/leaf-disease-inference-using-tez\" target=\"_blank\">this inference notebook</a>, or this pair that makes it very transparent: <a href=\"https://www.kaggle.com/muellerzr/recreating-abhishek-s-tez-with-fastai\" target=\"_blank\">training notebook</a> + <a href=\"https://www.kaggle.com/muellerzr/fastai-abhishek-inference\" target=\"_blank\">inference notebook</a>.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1104993,
          "author_name": "epochs19",
          "author_url": "",
          "post_date": "12/07/2020 12:49:37",
          "content": "<p>Here i created a notebook to demonstrate how to train with the internet on: <a href=\"https://www.kaggle.com/epochs19/superbeginner-training-notebook\" target=\"_blank\">https://www.kaggle.com/epochs19/superbeginner-training-notebook</a>  <br>\nHope this helps</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1105192,
          "author_name": "btseytlin",
          "author_url": "",
          "post_date": "12/07/2020 15:50:41",
          "content": "<p>Great, thank you!</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1199834,
          "author_name": "sbtk728",
          "author_url": "",
          "post_date": "02/14/2021 06:17:16",
          "content": "<p>I had same question,and could solve too!! It was very helpful!!<br>\nThank you!!</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1105292,
      "author_name": "thepowerfuldeez",
      "author_url": "",
      "post_date": "12/07/2020 18:25:26",
      "content": "<p>Hi! You can add your dataset with your pretrained models and add it to your notebook as an external source of data. Checkpoints can be accessed then as <code>/kaggle/input/NAME_OF_DATASET/your_model.pth</code></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1200671,
      "author_name": "vickygoyal",
      "author_url": "",
      "post_date": "02/14/2021 21:12:01",
      "content": "<p>You can refer the 2 notebooks for training and inference <a href=\"https://www.kaggle.com/c/cassava-leaf-disease-classification/discussion/216461\" target=\"_blank\">here</a></p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1103087": "I feel extremely silly asking this, but how do we use pretrained models with internet access disabled?\n\nI am trying to use models simply from `torchvision.models`, they attempt to download them from the internet, and then it fails.",
    "1103104": "You can create public or private dataset and import that dataset in your notebook , so now you can easily access those pretrained models in your code.\n\nHope this helped.",
    "1103215": "Thanks, this helps!",
    "1103293": "In fact, for something as popular as torchivision models, someone had probably already done it. It's the same for any popular packages that Kaggle happens to not include in their package selection. You'll find examples of the necessary sys.path.append(...) code in lots of public notebooks.",
    "1104345": "You can train in a notebook with the internet on and later load the trained model in a notebook exclusively for inference. The inference notebook would have the internet off.",
    "1104734": "How can this be done? I sensed this should be possible, but couldn't figure out how. Every time I try to submit, it says that I need to have internet off. So I turn it off, then \"save and run all\", it tries to run the whole notebook from scratch with internet off and fails.",
    "1104793": "You create two separate notebooks. One keeps the internet on and does the training of the model. In the second one, you switch the internet off and pick your other notebook as an input under \"Add data\". An example of this set-up is [this inference notebook](https://www.kaggle.com/abhishek/leaf-disease-inference-using-tez), or this pair that makes it very transparent: [training notebook](https://www.kaggle.com/muellerzr/recreating-abhishek-s-tez-with-fastai) + [inference notebook](https://www.kaggle.com/muellerzr/fastai-abhishek-inference).",
    "1104993": "Here i created a notebook to demonstrate how to train with the internet on: https://www.kaggle.com/epochs19/superbeginner-training-notebook  \nHope this helps",
    "1105192": "Great, thank you!",
    "1105292": "Hi! You can add your dataset with your pretrained models and add it to your notebook as an external source of data. Checkpoints can be accessed then as `/kaggle/input/NAME_OF_DATASET/your_model.pth`",
    "1199834": "I had same question,and could solve too!! It was very helpful!!\nThank you!!",
    "1200671": "You can refer the 2 notebooks for training and inference [here](https://www.kaggle.com/c/cassava-leaf-disease-classification/discussion/216461)"
  },
  "source": "meta"
}