(self)
| 193 | return arr.reshape(shape[0] * shape[1], *shape[2:]) |
| 194 | |
| 195 | def render(self): |
| 196 | assert self.full, '' |
| 197 | list_render = [] |
| 198 | |
| 199 | _, _, c, h, w = self.observations['birdview'].shape |
| 200 | vis_idx = np.array([0, 1, 2, 6, 10, 14]) |
| 201 | |
| 202 | for i in range(self.buffer_size): |
| 203 | im_envs = [] |
| 204 | for j in range(self.n_envs): |
| 205 | |
| 206 | masks = self.observations['birdview'][i, j, vis_idx, :, :] > 100 |
| 207 | |
| 208 | im_birdview = np.zeros([h, w, 3], dtype=np.uint8) |
| 209 | for idx_c in range(len(vis_idx)): |
| 210 | im_birdview[masks[idx_c]] = COLORS[idx_c] |
| 211 | |
| 212 | im = np.zeros([h, w*2, 3], dtype=np.uint8) |
| 213 | im[:h, :w] = im_birdview |
| 214 | |
| 215 | action_str = np.array2string(self.actions[i, j], precision=1, separator=',', suppress_small=True) |
| 216 | state_str = np.array2string(self.observations['state'][i, j], |
| 217 | precision=1, separator=',', suppress_small=True) |
| 218 | |
| 219 | reward = self.rewards[i, j] |
| 220 | ret = self.returns[i, j] |
| 221 | advantage = self.advantages[i, j] |
| 222 | done = int(self.dones[i, j]) |
| 223 | value = self.values[i, j] |
| 224 | log_prob = self.log_probs[i, j] |
| 225 | |
| 226 | txt_1 = f'v:{value:5.2f} p:{log_prob:5.2f} a{action_str}' |
| 227 | im = cv2.putText(im, txt_1, (2, 12), cv2.FONT_HERSHEY_SIMPLEX, 0.35, (255, 255, 255), 1) |
| 228 | txt_2 = f'{done} {state_str}' |
| 229 | im = cv2.putText(im, txt_2, (2, 24), cv2.FONT_HERSHEY_SIMPLEX, 0.35, (255, 255, 255), 1) |
| 230 | txt_3 = f'rw:{reward:5.2f} rt:{ret:5.2f} a:{advantage:5.2f}' |
| 231 | im = cv2.putText(im, txt_3, (2, 36), cv2.FONT_HERSHEY_SIMPLEX, 0.35, (255, 255, 255), 1) |
| 232 | |
| 233 | for i_txt, txt in enumerate(self.reward_debugs[j][i] + self.terminal_debugs[j][i]): |
| 234 | im = cv2.putText(im, txt, (w, (i_txt+1)*15), cv2.FONT_HERSHEY_SIMPLEX, 0.35, (255, 255, 255), 1) |
| 235 | |
| 236 | im_envs.append(im) |
| 237 | |
| 238 | big_im = tile_images(im_envs) |
| 239 | list_render.append(big_im) |
| 240 | |
| 241 | return list_render |
| 242 | |
| 243 | def start_caching(self, batch_size): |
| 244 | thread1 = Thread(target=self.cache_to_cuda, args=(batch_size,)) |
no outgoing calls
no test coverage detected