So I saved my resent-50 model after achieving an accuracy of 93% as follows
learn.export(‘train_resnet_model_50.pkl’). My learner is a cnn_learner(data, arch, metric=[acc_02, fbeta]) where arch = models.resent50.
Upon inspecting my path.ls() I get the fillowing
[PosixPath(’/root/.fastai/data/planet/train_v2.csv.zip’),
PosixPath(’/root/.fastai/data/planet/train_resnet_model_50.pkl’),
PosixPath(’/root/.fastai/data/planet/train-jpg.tar.7z’),
PosixPath(’/root/.fastai/data/planet/train-jpg’),
PosixPath(’/root/.fastai/data/planet/__MACOSX’),
PosixPath(’/root/.fastai/data/planet/models’),
PosixPath(’/root/.fastai/data/planet/train_v2.csv’)]
the second path seems to be the one where the model lives. How do I upload this file to google drive? I know this is absolutely trivial, But I also know that I don’t know how to. Like this is what I tried, I am not sure if this is the correct approach though?
from google.colab import files
files.download(’/root/.fastai/data/planet/train_resnet_model_50.pkl’), this downloads the file to my local machine but with an error that reads:
Exception happened during processing of request from (’::ffff:127.0.0.1’, 34680, 0, 0)
Traceback (most recent call last):
File “/usr/lib/python3.6/socketserver.py”, line 320, in _handle_request_noblock
self.process_request(request, client_address)
File “/usr/lib/python3.6/socketserver.py”, line 351, in process_request
self.finish_request(request, client_address)
File “/usr/lib/python3.6/socketserver.py”, line 364, in finish_request
self.RequestHandlerClass(request, client_address, self)
File “/usr/lib/python3.6/socketserver.py”, line 724, in init
self.handle()
File “/usr/lib/python3.6/http/server.py”, line 418, in handle
self.handle_one_request()
File “/usr/lib/python3.6/http/server.py”, line 406, in handle_one_request
method()
File “/usr/lib/python3.6/http/server.py”, line 639, in do_GET
self.copyfile(f, self.wfile)
File “/usr/lib/python3.6/http/server.py”, line 800, in copyfile
shutil.copyfileobj(source, outputfile)
File “/usr/lib/python3.6/shutil.py”, line 82, in copyfileobj
fdst.write(buf)
File “/usr/lib/python3.6/socketserver.py”, line 803, in write
self._sock.sendall(b)
ConnectionResetError: [Errno 104] Connection reset by peer
But after running that piece of code, I do have a file on my local machine named “train_resnet_model_50.pkl”. So I went ahead and uploaded this to my Google Drive by right-clicking on the My Drive folder and choosing the aforementioned file on my machine. Is this the right way to get a fastai model from colab into my google drive? The exception makes me really skeptical. Thanks a lot for helping me out, appreciate it.