I save my model using the following code.
def save(self, file_path, e):
torch.save(self.spatial_stream.state_dict(), os.path.join(file_path, ‘spt_{:03d}.pth’.format(e)))
torch.save(self.temporal_stream.state_dict(), os.path.join(file_path, ‘tmp_{:03d}.pth’.format(e)))
load:
def load(self, file_path):
self.load_state_dict(torch.load(file_path))
But I meet this problem,can you help me?Thank you very much !!!
Traceback (most recent call last):
File “/home/wuting/anaconda3/envs/python=3.8/lib/python3.8/site-packages/torch/serialization.py”, line 308, in _check_seekable
f.seek(f.tell())
AttributeError: ‘EasyDict’ object has no attribute ‘seek’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “test.py”, line 109, in
main()
File “test.py”, line 64, in main
epoch_loop.main()
File “/home/wuting/Spatialtem-multi/tools/epoch_loop.py”, line 70, in main
self.setup_net()
File “/home/wuting/Spatialtem-multi/tools/epoch_loop.py”, line 78, in setup_net
self.net = TwoStreamNet(self.device)
File “/home/wuting/Spatialtem-multi/lib/netwrapper/two_stream_net.py”, line 39, in init
self.create_load(device)
File “/home/wuting/Spatialtem-multi/lib/netwrapper/two_stream_net.py”, line 53, in create_load
self.load(cfg.CUS_PT_PATH)
File “/home/wuting/Spatialtem-multi/lib/netwrapper/two_stream_net.py”, line 207, in load
self.load_state_dict(torch.load(file_path))
File “/home/wuting/anaconda3/envs/python=3.8/lib/python3.8/site-packages/torch/serialization.py”, line 581, in load
with _open_file_like(f, ‘rb’) as opened_file:
File “/home/wuting/anaconda3/envs/python=3.8/lib/python3.8/site-packages/torch/serialization.py”, line 235, in _open_file_like
return _open_buffer_reader(name_or_buffer)
File “/home/wuting/anaconda3/envs/python=3.8/lib/python3.8/site-packages/torch/serialization.py”, line 220, in init
_check_seekable(buffer)
File “/home/wuting/anaconda3/envs/python=3.8/lib/python3.8/site-packages/torch/serialization.py”, line 311, in _check_seekable
raise_err_msg([“seek”, “tell”], e)
File “/home/wuting/anaconda3/envs/python=3.8/lib/python3.8/site-packages/torch/serialization.py”, line 304, in raise_err_msg
raise type(e)(msg)
AttributeError: ‘EasyDict’ object has no attribute ‘seek’. You can only torch.load from a file that is seekable. Please pre-load the data into a buffer like io.BytesIO and try to load from it instead.