1
Expressions={0:"Angry",1:"Disgust",2:"Fear",3:"Happy",4:"Sad",5:"Surprise",6:"Neutral"}
from keras.utils import to_categorical 
labels = to_categorical(labels,len(Expressions))
images = np.array([np.fromstring(pixel, dtype=int,sep=" ")for pixel in pixels])
images = images/255.00
images = images.reshape(images.reshape[0],48,48,1).astype('float32')

I'm getting this error while converting the grayscale image into 48x48, so anyone can give me a good response.

getting this error in the code;

  1 images = np.array([np.fromstring(pixel, dtype=int, sep=" ")for pixel in pixels])
  2 images = images/255.00
----> 3 images = images.reshape(images.reshape[0],48,48,1).astype('float32')

TypeError: 'builtin_function_or_method' object is not subscriptable

enter image description here

1 Answers1

1

reshape is a function. You have to change it to:

images = images.reshape(images.shape[0],48,48,1).astype('float32')

the first arg is images.shape[0] instead of images.reshape[0]

theletz
  • 1,713
  • 2
  • 16
  • 22