GrayScaleObservation

class GrayScaleObservation(env, keep_dim=True, key='img')[source]

Bases: ObservationWrapper

Convert the image observation from RGB to gray scale.

Mostly the same as the open ai gym implementation except this allows for the wrapper to be applied to a single element inside a Dict observation.

__init__(env, keep_dim=True, key='img')[source]

Initialze an object.

Parameters:
  • env (gym environment) – Environment to wrap.

  • keep_dim (bool, optional) – Flag indicating if the channel dimension should be kept. The default is True.

  • key (string, optional) – Key in teh dictionary corresponding to the image. The default is ‘img’.

Methods

__init__

Initialze an object.

class_name

Returns the class name of the wrapper.

close

Closes the environment.

observation

Generates the proper observation.

render

reset

Resets the environment, returning a modified observation using self.observation().

seed

Seeds the environment.

step

Returns a modified observation using self.observation() after calling env.step().

Attributes

action_space

Returns the action space of the environment.

metadata

Returns the environment metadata.

np_random

Returns the environment np_random.

observation_space

Returns the observation space of the environment.

render_mode

Returns the environment render_mode.

reward_range

Return the reward range of the environment.

spec

Returns the environment specification.

unwrapped

Returns the base environment of the wrapper.

classmethod class_name()

Returns the class name of the wrapper.

close()

Closes the environment.

observation(obs)[source]

Generates the proper observation.

reset(**kwargs)

Resets the environment, returning a modified observation using self.observation().

seed(seed=None)

Seeds the environment.

step(action)

Returns a modified observation using self.observation() after calling env.step().

property action_space: Space[ActType]

Returns the action space of the environment.

property metadata: dict

Returns the environment metadata.

property np_random: RandomNumberGenerator

Returns the environment np_random.

property observation_space: Space

Returns the observation space of the environment.

property render_mode: str | None

Returns the environment render_mode.

property reward_range: Tuple[SupportsFloat, SupportsFloat]

Return the reward range of the environment.

property spec

Returns the environment specification.

property unwrapped: Env

Returns the base environment of the wrapper.