1
0
mirror of https://github.com/gryf/coach.git synced 2025-12-17 11:10:20 +01:00

allow visualizing the observation + bug fixes to coach summary

This commit is contained in:
Itai Caspi
2018-02-13 18:47:24 +02:00
committed by Itai Caspi
parent 5d1a2bc392
commit 55c8c87afc
4 changed files with 14 additions and 2 deletions

View File

@@ -22,6 +22,7 @@ except:
failed_imports.append("matplotlib")
import copy
from renderer import Renderer
from configurations import Preset
from collections import OrderedDict
from utils import RunPhase, Signal, is_empty, RunningStat
@@ -101,6 +102,7 @@ class Agent(object):
self.main_network = None
self.networks = []
self.last_episode_images = []
self.renderer = Renderer()
# signals
self.signals = []
@@ -232,6 +234,13 @@ class Agent(object):
r, g, b = observation[:, :, 0], observation[:, :, 1], observation[:, :, 2]
observation = 0.2989 * r + 0.5870 * g + 0.1140 * b
# Render the processed observation which is how the agent will see it
# Warning: this cannot currently be done in parallel to rendering the environment
if self.tp.visualization.render_observation:
if not self.renderer.is_open:
self.renderer.create_screen(observation.shape[0], observation.shape[1])
self.renderer.render_image(observation)
return observation.astype('uint8')
else:
if self.tp.env.normalize_observation: