Pre-processing step for an observation from a ``gym`` environment.
(self)
| 203 | self.env.close() |
| 204 | |
| 205 | def preprocess(self) -> None: |
| 206 | # language=rst |
| 207 | """ |
| 208 | Pre-processing step for an observation from a ``gym`` environment. |
| 209 | """ |
| 210 | if self.name == "SpaceInvaders-v0": |
| 211 | self.obs = subsample(gray_scale(self.obs), 84, 110) |
| 212 | self.obs = self.obs[26:104, :] |
| 213 | self.obs = binary_image(self.obs) |
| 214 | elif self.name == "BreakoutDeterministic-v4": |
| 215 | self.obs = subsample(gray_scale(crop(self.obs, 34, 194, 0, 160)), 80, 80) |
| 216 | self.obs = binary_image(self.obs) |
| 217 | else: # Default pre-processing step. |
| 218 | pass |
| 219 | |
| 220 | self.obs = torch.from_numpy(self.obs).float() |
| 221 | |
| 222 | def update_history(self) -> None: |
| 223 | # language=rst |
no test coverage detected