mirror of
https://github.com/saymrwulf/stable-baselines3.git
synced 2026-09-16 22:20:26 +00:00
clarified bytesIO use for load
This commit is contained in:
parent
bac9d4efed
commit
aa67147796
1 changed files with 4 additions and 2 deletions
|
|
@ -359,7 +359,8 @@ class BaseRLModel(object):
|
||||||
if "params.pth" in namelist:
|
if "params.pth" in namelist:
|
||||||
# Load parameters with build in torch function
|
# Load parameters with build in torch function
|
||||||
with archive.open("params.pth", mode="r") as param_file:
|
with archive.open("params.pth", mode="r") as param_file:
|
||||||
# File has to be seekable so load in BytesIO first
|
# File has to be seekable, but param_file is not, so load in BytesIO first
|
||||||
|
# fixed in python >= 3.7
|
||||||
file_content = io.BytesIO()
|
file_content = io.BytesIO()
|
||||||
file_content.write(param_file.read())
|
file_content.write(param_file.read())
|
||||||
# go to start of file
|
# go to start of file
|
||||||
|
|
@ -375,7 +376,8 @@ class BaseRLModel(object):
|
||||||
opt_params = dict()
|
opt_params = dict()
|
||||||
for file_path in other_files:
|
for file_path in other_files:
|
||||||
with archive.open(file_path, mode="r") as opt_param_file:
|
with archive.open(file_path, mode="r") as opt_param_file:
|
||||||
# File has to be seekable so load in BytesIO first
|
# File has to be seekable, but opt_param_file is not, so load in BytesIO first
|
||||||
|
# fixed in python >= 3.7
|
||||||
file_content = io.BytesIO()
|
file_content = io.BytesIO()
|
||||||
file_content.write(opt_param_file.read())
|
file_content.write(opt_param_file.read())
|
||||||
# go to start of file
|
# go to start of file
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue