本文介绍了将文件从kaggle上传到Google驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用kaggle训练模型,训练完成后,我想将训练后的模型上传到google驱动器,因为我找不到在本地下载模型的方法.在尝试进行身份验证的pip install pydrive后,我考虑使用 https://pythonhosted.org/PyDrive/ /p>

I am using kaggle to train a model and once training is done I would like upload the trained model to google drive as I cant figure out a way to download the model locally. I looked into using https://pythonhosted.org/PyDrive/ after doing pip install pydrive I tried authenticating

    import os
    from pydrive.auth import GoogleAuth
    from pydrive.drive import GoogleDrive
    from oauth2client.client import GoogleCredentials

然后

gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

我收到此错误ApplicationDefaultCredentialsError:应用程序默认凭据不可用.如果它们在Google Compute Engine中运行,则可用.否则,必须定义环境变量GOOGLE_APPLICATION_CREDENTIALS指向指向定义凭据的文件.请参见 https://developers.google.com/accounts/docs/application-default -凭证以获取更多信息.

I get this errorApplicationDefaultCredentialsError: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.

还有另一种方法吗?

我还没有在kaggle中提交文件,因为我手动停止了培训,因此提交将永远继续下去,在尝试在输出区域中提交并停止提交后,我收到了6个以上的子目录错误

Also I have not commited my files in kaggle as I stop the training manually so the commit would go on forever and i get a more than 6 subdirectories error after I tried commiting and stopping a commit in the output area

推荐答案

我遇到了同样的问题,可以将文件从Kaggle下载到Colab,然后移动到Google Drive.例如,如果当前目录为/kaggle/working,要移动的文件为processed_file.zip,则

I was facing the same problem and was able download files from Kaggle to Colab then move to Google Drive. For example, if the current directory is /kaggle/working and the file to move is processed_file.zip then,

from IPython.display import FileLink
FileLink(r'processed_file.zip')

这将生成一个链接,

https://....kaggle.net/...../processed_file.zip

来自Colab

!wget "https://....kaggle.net/...../processed_file.zip"

安装Google云端硬盘

from google.colab import drive
drive.mount('/content/drive')

移动到Google云端硬盘

!cp "/content/processed_file.zip" "/content/drive/My Drive/workspace"

这篇关于将文件从kaggle上传到Google驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 13:54