Convert-own-data-to-MNIST-format
Convert-own-data-to-MNIST-format copied to clipboard
list index out of range
What does it mean?
C:\PROGRAMOWANIE\Python_OCR\Convert-own-data-to-MNIST-format-master\Convert-own-
data-to-MNIST-format-master>python convert_to_mnist_format.py C:\PROGRAMOWANIE\P
ython\OCR_Math\training_images 10
Traceback (most recent call last):
File "convert_to_mnist_format.py", line 215, in
Hi @boloslaw , I help my friend to deal with this project, and also encounter this problem. Some experience can share to you. I just run the following command:
$ python3 convert_to_mnist_format.py dataset 0
But the same error occurs.
After I trace the code, the variable labelsAndFiles
is empty.
The rough guess is that the image format is not PNG.
In the make_array
function, the program only consider .png
format.
Maybe you can just revise like this in line 87:
for file in os.listdir(dirname):
if (file.endswith('.png')):
fullname = os.path.join(dirname, file)
to become like this:
for file in os.listdir(dirname):
if (file.endswith('.png') or file.endswith('.jpg')):
fullname = os.path.join(dirname, file)
Moreover, just append other condition if your image format is neither PNG nor JPG. The only thing you need to do is waiting it complete!