Pytorch 在不使用互联网的情况下,在Kaggle内核中加载预训练的FastAI模型

Pytorch 在不使用互联网的情况下,在Kaggle内核中加载预训练的FastAI模型,pytorch,kaggle,fast-ai,densenet,Pytorch,Kaggle,Fast Ai,Densenet,我正在尝试在Kaggle内核中加载densenet121模型,而无需在internet上切换。 我已经完成了所需的步骤,例如将预先训练好的权重添加到输入目录并将其移动到“.cache/torch/checkpoints/”中。它仍然无法工作,并抛出一个错误 以下是代码片段: !mkdir -p /tmp/.cache/torch/checkpoints !cp ../input/fastai-pretrained-models/densenet121-a639ec97.pth /tmp/.cac

我正在尝试在Kaggle内核中加载densenet121模型,而无需在internet上切换。 我已经完成了所需的步骤,例如将预先训练好的权重添加到输入目录并将其移动到“.cache/torch/checkpoints/”中。它仍然无法工作,并抛出一个错误

以下是代码片段:

!mkdir -p /tmp/.cache/torch/checkpoints
!cp ../input/fastai-pretrained-models/densenet121-a639ec97.pth /tmp/.cache/torch/checkpoints/densenet121-a639ec97.pth

learn_cd = create_cnn(data_cd, models.densenet121, metrics=[error_rate, accuracy],model_dir = Path('../kaggle/working/models'),path=Path('.'),).to_fp16()
我已经为此奋斗了很长时间。任何帮助都会非常有用,所以kaggle内核中的输入路径“./input/”是只读的。在“kaggle/working”中创建一个文件夹,并将模型权重复制到该文件夹中。下面的例子

if not os.path.exists('/root/.cache/torch/hub/checkpoints/'):
        os.makedirs('/root/.cache/torch/hub/checkpoints/')

!mkdir '/kaggle/working/resnet34'
!cp '/root/.cache/torch/hub/checkpoints/resnet34-333f7ec4.pth' '/kaggle/working/resnet34/resnet34.pth'