download model on google colab

867 views
Skip to first unread message

Sylvain Ard

unread,
Mar 23, 2020, 6:05:34 AM3/23/20
to Discuss
Hi,
I wanted to download my model in google colab with :
# Install the PyDrive wrapper & import libraries.
# This only needs to be done once in a notebook.
!pip install -U -q PyDrive
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials

# Authenticate and create the PyDrive client.
# This only needs to be done once in a notebook.
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

# Create & upload a file.
uploaded = drive.CreateFile({'title': './strt4_80im'})
uploaded.SetContentFile('strt4_80im')
uploaded.Upload()
print('Uploaded file with ID {}'.format(uploaded.get('id')))

but got the error :
(...)

   1692                     # Fix-up relative redirects (which violate an RFC 2616 MUST)

RedirectMissingLocation: Redirected but the response is missing a Location: header.

please help me !
thank you :)
bye

Lance Norskog

unread,
Mar 23, 2020, 1:16:26 PM3/23/20
to Sylvain Ard, Discuss
Suggest filing a bug report on the colab-tools github.


--
You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+u...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/e2c6ba90-5899-4e28-9adc-8a19ea317485%40tensorflow.org.


--
Lance Norskog
lance....@gmail.com
Redwood City, CA

Eduardo A. Flores Verduzco

unread,
Mar 23, 2020, 1:45:58 PM3/23/20
to Discuss
Hi, I'm not sure if this solution may work for you but I avoid using the python API by using system commands directly, like:

Enter code here...%tensorflow_version 2.x
from google.colab import drive
drive.mount('/content/drive')
!pip install tensorflow-text
!pip install transformers
!mkdir ../data
!mkdir ../saved_models
!mkdir ../logs
!cp /content/drive/My\ Drive/datasets/lang_model_eval/* ../data/.
!cp -r /content/drive/My\ Drive/datasets/lang_model_eval/cache ../cache

And to save my results back to drive:

Enter code here...!cp -r /experiments/lmevME-LM/NNLM_128-v1 /content/drive/My\ Drive/datasets/lang_model_eval/results-ME/.


Sylvain Ard

unread,
Mar 23, 2020, 1:48:43 PM3/23/20
to Discuss
I finally downloaded it by the Google Colab interface

Lance Norskog

unread,
Mar 23, 2020, 11:05:40 PM3/23/20
to Sylvain Ard, Discuss
One thing I've noticed is that when you create a file on the Colab VM drive, then immediately copy it to the Google Drive mount, it takes maybe 5-10 seconds before the local file system can reliably find the file you just made. So instead of:

code to create file
!cp file /content/gdrive/My Drive/Colab Notebooks/data/

I need:

code to create file
!sleep 10
!cp file /content/gdrive/My Drive/Colab Notebooks/data




--
You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+u...@tensorflow.org.
Reply all
Reply to author
Forward
0 new messages