a2c-Walker2DBulletEnv-v0 / wrappers /video_compat_wrapper.py
sgoodfriend's picture
A2C playing Walker2DBulletEnv-v0 from https://github.com/sgoodfriend/rl-algo-impls/tree/0760ef7d52b17f30219a27c18ba52c8895025ae3
aa3f47c
raw
history blame
No virus
447 Bytes
import gym
import numpy as np
from wrappers.vectorable_wrapper import VecotarableWrapper
class VideoCompatWrapper(VecotarableWrapper):
def __init__(self, env: gym.Env) -> None:
super().__init__(env)
def render(self, mode="human", **kwargs):
r = super().render(mode=mode, **kwargs)
if mode == "rgb_array" and isinstance(r, np.ndarray) and r.dtype != np.uint8:
r = r.astype(np.uint8)
return r