def _convert(self, obs):
     self.obs_buffer.append(obs)
     max_frame = np.max(np.stack(self.obs_buffer), axis=0)
     intensity_frame = rgb2y(max_frame).astype(np.uint8)
     small_frame = np.array(Image.fromarray(intensity_frame).resize(
         (self.hei_state, self.wid_state), resample=Image.BILINEAR),
                            dtype=np.uint8)
     return small_frame
예제 #2
0
 def _preprocessState(self, state):
     if self.preprocess_mode == 3:   # crop then resize
         state = preprocessAtari(state)
     if self.preprocess_mode == 2:   # rgb2y
         state = scale(rgb2y(state), self.hei_state, self.wid_state) / 255.
     elif self.preprocess_mode == 1: # rgb2gray
         state = scale(rgb2gray(state), self.hei_state, self.wid_state) / 255.
     elif self.preprocess_mode == 0: # do nothing
         pass
     return state.reshape(self.hei_state * self.wid_state)