File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change 158158import numpy as np
159159import tensorflow as tf
160160import gym
161- import scipy
161+ import PIL . Image
162162import sys
163163import os
164164import time
@@ -405,6 +405,9 @@ def print_progress(msg):
405405# Size of each image in the state.
406406state_img_size = np .array ([state_height , state_width ])
407407
408+ # Size of each image in the state. Reversed order used by PIL.Image.
409+ state_img_size_reverse = tuple (reversed (state_img_size ))
410+
408411# Number of images in the state.
409412state_channels = 2
410413
@@ -435,12 +438,19 @@ def _pre_process_image(image):
435438 """Pre-process a raw image from the game-environment."""
436439
437440 # Convert image to gray-scale.
438- img = _rgb_to_grayscale (image )
441+ img_gray = _rgb_to_grayscale (image = image )
442+
443+ # Create PIL-object from numpy array.
444+ img = PIL .Image .fromarray (img_gray )
445+
446+ # Resize the image.
447+ img_resized = img .resize (size = state_img_size_reverse ,
448+ resample = PIL .Image .LINEAR )
439449
440- # Resize to the desired size using SciPy for convenience .
441- img = scipy . misc . imresize ( img , size = state_img_size , interp = 'bicubic' )
450+ # Convert 8-bit pixel values back to floating-point .
451+ img_resized = np . float32 ( img_resized )
442452
443- return img
453+ return img_resized
444454
445455
446456class MotionTracer :
You can’t perform that action at this time.
0 commit comments