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

IndexError: too many indices for array #1

Open
exgile opened this issue May 30, 2016 · 5 comments
Open

IndexError: too many indices for array #1

exgile opened this issue May 30, 2016 · 5 comments

Comments

@exgile
Copy link

exgile commented May 30, 2016

When i run main.py, it show some error

Traceback (most recent call last):
File "main.py", line 144, in
main()
File "main.py", line 112, in main
content_img = read_image(CONTENT_IMG)
File "main.py", line 96, in read_image
image = image[np.newaxis,:IMAGE_H,:IMAGE_W,:]
IndexError: too many indices for array

how do i fix it, Thx

@webmaven
Copy link

webmaven commented Jul 3, 2016

@exgile, is this still an issue?

@AlessioTonioni
Copy link

AlessioTonioni commented Jul 7, 2016

I had the same problem using anaconda with python 3.5.
This seems related to the io module of scipy that uses 'PIL' to load and save image, at least in my case the image loaded from the disk was an empty array with only a descriptive header string, that's what caused the error when trying to slice it.
Anyway I have solved installing 'pillow' instead of 'PIL' with pip.

@francescoagati
Copy link

i have installed pillow but have the same problem. have you change something in the script for use pillow instad of PIL?

@francescoagati
Copy link

i use python 2.7.6 on bash ubuntu

@ckmarkoh
Copy link
Owner

Now, I replace this line by scipy.misc.imresize(image,(IMAGE_H,IMAGE_W)).
I hope this could solve this issue.
If it can't, it is recommended to use other image-processing libraries such as cv2 or skimage.
So that it can read an image as three dimensional numpy array.

Actually, when I created this project two years ago, I was not familiar with python API for image processing, and I didn't know how to resize image.

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

No branches or pull requests

5 participants