emotion-recognition-neural-networks icon indicating copy to clipboard operation
emotion-recognition-neural-networks copied to clipboard

Conversion error

Open Zumbalamambo opened this issue 7 years ago • 4 comments

Im getting the following error while conversion

File "cvs_to_numpy.py", line 71, in <module>
    image = data_to_image(row['pixels'])
  File "cvs_to_numpy.py", line 59, in data_to_image
    data_image = format_image(data_image)
  File "cvs_to_numpy.py", line 16, in format_image
    gray_border[((150 / 2) - (SIZE_FACE/2)):((150/2)+(SIZE_FACE/2)), ((150/2)-(SIZE_FACE/2)):((150/2)+(SIZE_FACE/2))] = image
TypeError: slice indices must be integers or None or have an __index__ method

Zumbalamambo avatar Aug 21 '17 07:08 Zumbalamambo

you need to give integers to reach indices of gray_border. use a int(float f) to make sure you get it right.

AdrienPlayerium avatar Sep 19 '17 23:09 AdrienPlayerium

@AdrienPlayerium i didn't get it. can you tell how to solve this problem?

mrinal18 avatar Feb 08 '18 06:02 mrinal18

@Mrinal18 In this code sample, he got a numpy array which contains pixel information, to pick the region of interest you got to pick a part of this matrix, that's what he tried above. It's almost correct, the error is raised because the slices: ((150 / 2) - (SIZE_FACE/2)):((150/2)+(SIZE_FACE/2)):((150/2)-(SIZE_FACE/2)):((150/2)+(SIZE_FACE/2)) "select square of SIZE_FACE around (150/2,150/2) position" is not well defined since the type of those numbers are floats... therefore a quick fix would be to cast to integers: int((150 / 2) - (SIZE_FACE/2)):int((150/2)+(SIZE_FACE/2)):int((150/2)-(SIZE_FACE/2)):int((150/2)+(SIZE_FACE/2))

AdrienPlayerium avatar Feb 09 '18 00:02 AdrienPlayerium

Got it. Thank you very much.

mrinal18 avatar Feb 09 '18 05:02 mrinal18