Closed anayebi closed 1 year ago
Hello,
I guess your issue is a duplicate of https://github.com/DLR-RM/rl-baselines3-zoo/pull/379 (see dicussion in https://github.com/DLR-RM/stable-baselines3/pull/1525)
I thought the bug was fixed but it is still there apparently...
and yes env = VecNormalize.load(path_, env)
is the issue, when the VecNormalize is unpickled, some attributes are not set properly (self.class_attributes
doesn't contain render_mode
).
A fix would be to do self.render_mode = self.venv.render_mode
L166 of the VecNormalize
(right after self.class_attributes = dict(inspect.getmembers(self.__class__))
)
I've pushed a fix here: https://github.com/DLR-RM/stable-baselines3/pull/1671/files
Great, thanks so much! Hopefully it gets merged to master soon :)
Released on master branch =)
🐛 Bug
The
render_mode
inrecord_video.py
is not preserved aftercreate_test_env
is called here: https://github.com/DLR-RM/rl-baselines3-zoo/blob/2d5db11f6aee6d231d2154849715b0f7a9435038/rl_zoo3/record_video.py#L96-L105.I have traced it to exactly this line in
utils.py
, where theVecNormalize
wrapper of Stable-Baselines3 seems to set it back toNone
: https://github.com/DLR-RM/rl-baselines3-zoo/blob/2d5db11f6aee6d231d2154849715b0f7a9435038/rl_zoo3/utils.py#L284.My temporary solution was to set
env.render_mode = 'rgb_array'
back inrecord_video.py
right aftercreate_test_env
: https://github.com/DLR-RM/rl-baselines3-zoo/blob/2d5db11f6aee6d231d2154849715b0f7a9435038/rl_zoo3/record_video.py#L106, but I think a more general solution should be developed to ensure kwargs are preserved by environment wrappers.To Reproduce
Relevant log output / Error message
System Info
Library was installed via
pip
.Checklist