Skip to content

ValueError: ('Cannot warp empty image with dimensions', (0, 24)) #77

@EXJUSTICE

Description

@EXJUSTICE

Hello,

I've tried adapting your approach during training to some pre-existing code of mine,
however I am constantly met with the ValueError. My model is different from yours, but essentially does the same procedure. My original training approach had a check for while not done, but as the first episode quits early (?) There would always be some error, and hence I wanted to try your approach.
https://gist.github.com/EXJUSTICE/0df29caedee2a72a7e5faf7aa88cbd03

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-159-aebc713aaeac> in <module>()
     63               next_obs=np.zeros(obs.shape)
     64 
---> 65               next_obs,stacked_frames= stack_frames(stacked_frames,next_obs,False)
     66               step = max_steps
     67               history.append(episodic_reward)

3 frames
/usr/local/lib/python3.6/dist-packages/skimage/transform/_warps.py in warp(image, inverse_map, map_args, output_shape, order, mode, cval, clip, preserve_range)
    805 
    806     if image.size == 0:
--> 807         raise ValueError("Cannot warp empty image with dimensions", image.shape)
    808 
    809     image = convert_to_float(image, preserve_range)

ValueError: ('Cannot warp empty image with dimensions', (0, 24))

After investigating, it's clear to me that the error is from the preprocessing function, where you call to transform the preprocessed image to size 84,84 using sci-image. I changed your code to ensure that grayscaling happened as well. The transformation cannot occur with an empty array of zeros?

def preprocess_observation(frame):

    # Crop and resize the image into a square, as we don't need the excess information
    cropped = frame[60:-60,30:-30]

    normalized = cropped/255.0

    # Improve image contrast See if works
    #img[img==color] = 0

    # Next we normalize the image from -1 to +1 See if works
    #img = (img - 128) / 128 - 1

    
    img_gray = rgb2gray(normalized)

    preprocessed_frame = transform.resize(img_gray, [84,84])

    return preprocessed_frame

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions