Hi all,
First of, this is not an issue but a request/question I guess this would be a more relevant question for stackoverflow but my guess is that it may be harder to get an answer there. For a very specific application I'm working on the current screen size of the environment produced by the atari environment is way to small, is there any way to modify the screen size without modifying atary_py?
I checked in atary_py and could not find a way to do it there.
Indeed, on Retina Macs the image is kinda hard to see. The logic is in gym.envs.classic_control.rendering.SimpleImageViewer at https://github.com/openai/gym/blob/master/gym/envs/classic_control/rendering.py#L315 if someone wants to make an attempt at enlarging it. As a proposed policy:
if is_retina:
scale = max(1, 1000//max(width, height))
else:
scale = max(1, 500//max(width, height))
Investigating this issue. Turns out that using pyglet to get screen resolution on a Retina screen results in scaled, not true dimensions.
import pyglet
platform = pyglet.window.get_platform()
display = platform.get_default_display()
screen = display.get_default_screen()
screen
// CocoaScreen(x=0, y=0, width=1280, height=800)
Now searching for other means of detecting a scaled screen. The pyglet team seems aware of this issue, perhaps we can use their fix...
Hi all,
I actually found the next fix, not sure where I found it but it works
from gym.envs.classic_control import rendering
def repeat_upsample(rgb_array, k=1, l=1, err=[]):
# repeat kinda crashes if k/l are zero
if k <= 0 or l <= 0:
if not err:
print "Number of repeats must be larger than 0, k: {}, l: {}, returning default array!".format(k, l)
err.append('logged')
return rgb_array
# repeat the pixels k times along the y axis and l times along the x axis
# if the input image is of shape (m,n,3), the output image will be of shape (k*m, l*n, 3)
return np.repeat(np.repeat(rgb_array, k, axis=0), l, axis=1)
viewer = rendering.SimpleImageViewer()
env = gym.make(mapName)
env.reset()
action=0
while run:
rgb = env.render('rgb_array')
upscaled=repeat_upsample(rgb,4, 4)
viewer.imshow(upscaled)
observation, reward, done, info = env.step(action)
Okay, glad to hear it. @tlbtlbtlb let me know if you're still interested in a solution within Gym itself.
Most helpful comment
Hi all,
I actually found the next fix, not sure where I found it but it works