Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DQNCar.py returns error on image reshaping #1840

Closed
hrshovon opened this issue Mar 15, 2019 · 2 comments
Closed

DQNCar.py returns error on image reshaping #1840

hrshovon opened this issue Mar 15, 2019 · 2 comments
Labels

Comments

@hrshovon
Copy link

hrshovon commented Mar 15, 2019

Airsim version: 1.2
Car environment: Unity
Python file: DQNcar.py

Whenever I try to run this code, I get this error:

Traceback (most recent call last):
  File "DQNcar.py", line 513, in <module>
    current_state = transform_input(responses)
  File "DQNcar.py", line 434, in transform_input
    img2d = np.reshape(img1d, (responses[0].height, responses[0].width))
  File "C:\Users\shovon\AppData\Local\conda\conda\envs\ml_agents\lib\site-packages\numpy\core\fromnumeric.py", line 257, in reshape
    return _wrapfunc(a, 'reshape', newshape, order=order)
  File "C:\Users\shovon\AppData\Local\conda\conda\envs\ml_agents\lib\site-packages\numpy\core\fromnumeric.py", line 52, in _wrapfunc
    return getattr(obj, method)(*args, **kwds)
ValueError: cannot reshape array of size 1 into shape (144,256)

I tried to manually print output of responses[0].image_data_float but I only get [0.]

Any solutions?
TIA.

@msb336
Copy link
Contributor

msb336 commented Mar 29, 2019

The airsim server sometimes returns an empty image message, which is why reshaping causes this value error. We are still looking into why the image return is sometimes empty, but as a workaround, you can add a logical catch for when these empty images are returned:

if img1d.size == responses[0].height * responses[0].width:
    # reshape image
else:
    #image is empty

@rallen10
Copy link

I'm still getting this same error and it doesn't seem to just be me (#2169). Perhaps this issue should be opened again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants