{
  "id": 145861,
  "title": "Model download and initialization issue !",
  "url": "/competitions/prostate-cancer-grade-assessment/discussion/145861",
  "author_name": "abhiswain",
  "post_date": "2020-04-24T20:03:53.669000",
  "votes": 1,
  "comment_count": 4,
  "views": 0,
  "content": "<p>I am a beginner here at Kaggle. This is my first competition. I have trained my model.\nNow when I am trying to infer I run into a lot of issues. Here is my issue:</p>\n\n<p>I am using a pre-trained model(resnet50 to be precise). After training, I try to infer from my model for that I add my model to my kernel as a dataset, now in my code to load the pre-trained-weights first I need to initialize the model with the class I created. \n<code>model = torchvision.models.resnet50(pretrained=True)</code>\nThis line downloads the model, but according to the submission requirements I need to turn the internet off and commit my code. So when the code is rerun during the commit this line causes an error as it cannot download the model. How do I solve this? Does that mean I need to implement resnet50 from scratch? Is there any other way? I want to know. What am I missing?</p>",
  "messages": [
    {
      "id": 819767,
      "postDate": "2020-04-24T20:54:35.243Z",
      "content": "<p>You can use Kaggle datasets to import a pre-trained model. You could upload your own or use one that someone else has already uploaded such as: <a href=\"https://www.kaggle.com/keras/resnet50\">https://www.kaggle.com/keras/resnet50</a></p>",
      "rawMarkdown": "You can use Kaggle datasets to import a pre-trained model. You could upload your own or use one that someone else has already uploaded such as: https://www.kaggle.com/keras/resnet50",
      "votes": 1,
      "replies": [
        {
          "id": 819791,
          "postDate": "2020-04-24T21:39:32.287Z",
          "content": "<p>hey there! I am using my own pre-trained model only. But in PyTorch before using the model we need to initialize it with the class using which we created it! This class downloads the pre-trained model. After that, we can load the weights of the saved model. But the class initialization is where the issue occurs as initialization downloads the model. This requires the internet but we need to switch it off right? so how to solve this. </p>",
          "rawMarkdown": "hey there! I am using my own pre-trained model only. But in PyTorch before using the model we need to initialize it with the class using which we created it! This class downloads the pre-trained model. After that, we can load the weights of the saved model. But the class initialization is where the issue occurs as initialization downloads the model. This requires the internet but we need to switch it off right? so how to solve this. "
        },
        {
          "id": 819840,
          "postDate": "2020-04-24T23:23:40.470Z",
          "content": "<p>From what I understand, the models are built into torchvision and do not need to be downloaded. The fact that you're passing pretrained=True makes it try to download weights into cache. If you just set that to False, it should load the model structure without downloading any weights.</p>",
          "rawMarkdown": "From what I understand, the models are built into torchvision and do not need to be downloaded. The fact that you're passing pretrained=True makes it try to download weights into cache. If you just set that to False, it should load the model structure without downloading any weights.",
          "votes": 1
        },
        {
          "id": 819848,
          "postDate": "2020-04-24T23:40:49.467Z",
          "content": "<p>Thank you I actually solved it </p>",
          "rawMarkdown": "Thank you I actually solved it ",
          "votes": 1
        }
      ]
    },
    {
      "id": 819735,
      "postDate": "2020-04-24T20:03:53.670Z",
      "content": "<p>I am a beginner here at Kaggle. This is my first competition. I have trained my model.\nNow when I am trying to infer I run into a lot of issues. Here is my issue:</p>\n\n<p>I am using a pre-trained model(resnet50 to be precise). After training, I try to infer from my model for that I add my model to my kernel as a dataset, now in my code to load the pre-trained-weights first I need to initialize the model with the class I created. \n<code>model = torchvision.models.resnet50(pretrained=True)</code>\nThis line downloads the model, but according to the submission requirements I need to turn the internet off and commit my code. So when the code is rerun during the commit this line causes an error as it cannot download the model. How do I solve this? Does that mean I need to implement resnet50 from scratch? Is there any other way? I want to know. What am I missing?</p>",
      "rawMarkdown": "I am a beginner here at Kaggle. This is my first competition. I have trained my model.\nNow when I am trying to infer I run into a lot of issues. Here is my issue:\n\nI am using a pre-trained model(resnet50 to be precise). After training, I try to infer from my model for that I add my model to my kernel as a dataset, now in my code to load the pre-trained-weights first I need to initialize the model with the class I created. \n`model = torchvision.models.resnet50(pretrained=True)`\nThis line downloads the model, but according to the submission requirements I need to turn the internet off and commit my code. So when the code is rerun during the commit this line causes an error as it cannot download the model. How do I solve this? Does that mean I need to implement resnet50 from scratch? Is there any other way? I want to know. What am I missing?",
      "votes": 1
    }
  ],
  "comments": [
    {
      "id": 819767,
      "author_name": "Matt",
      "author_url": "",
      "post_date": "2020-04-24T20:54:35.243000",
      "content": "<p>You can use Kaggle datasets to import a pre-trained model. You could upload your own or use one that someone else has already uploaded such as: <a href=\"https://www.kaggle.com/keras/resnet50\">https://www.kaggle.com/keras/resnet50</a></p>",
      "votes": 1,
      "replies": [
        {
          "id": 819791,
          "author_name": "abhiswain",
          "author_url": "",
          "post_date": "2020-04-24T21:39:32.287000",
          "content": "<p>hey there! I am using my own pre-trained model only. But in PyTorch before using the model we need to initialize it with the class using which we created it! This class downloads the pre-trained model. After that, we can load the weights of the saved model. But the class initialization is where the issue occurs as initialization downloads the model. This requires the internet but we need to switch it off right? so how to solve this. </p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 819840,
          "author_name": "Matt",
          "author_url": "",
          "post_date": "2020-04-24T23:23:40.470000",
          "content": "<p>From what I understand, the models are built into torchvision and do not need to be downloaded. The fact that you're passing pretrained=True makes it try to download weights into cache. If you just set that to False, it should load the model structure without downloading any weights.</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 819848,
          "author_name": "abhiswain",
          "author_url": "",
          "post_date": "2020-04-24T23:40:49.467000",
          "content": "<p>Thank you I actually solved it </p>",
          "votes": 1,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "819767": "You can use Kaggle datasets to import a pre-trained model. You could upload your own or use one that someone else has already uploaded such as: https://www.kaggle.com/keras/resnet50",
    "819735": "I am a beginner here at Kaggle. This is my first competition. I have trained my model.\nNow when I am trying to infer I run into a lot of issues. Here is my issue:\n\nI am using a pre-trained model(resnet50 to be precise). After training, I try to infer from my model for that I add my model to my kernel as a dataset, now in my code to load the pre-trained-weights first I need to initialize the model with the class I created. \n`model = torchvision.models.resnet50(pretrained=True)`\nThis line downloads the model, but according to the submission requirements I need to turn the internet off and commit my code. So when the code is rerun during the commit this line causes an error as it cannot download the model. How do I solve this? Does that mean I need to implement resnet50 from scratch? Is there any other way? I want to know. What am I missing?"
  }
}