How to read StackTrace of Error

The problem is that you have spaces in the name of each label. That means it thinks there are two labels, “Fat”, and “Hen”. Replace the spaces with underscores to fix this.


I tried both workarounds:

  1. Increasing the ulimit for number of files open by process as suggested by @KevinB
  2. Replace spaces in underscores as suggested by @jeremy

and the one that got me past the error was #2 (replacing spaces with underscores). Here is the updated code snippet I’m using to produce the csv file:

df = pd.DataFrame(columns=["file", "species"])

for image in glob("{}/train/**/*.png".format(PATH)):
    dir_ = image.split('/')
    file_, species = dir_[-1], dir_[-2]
    # "Fat hen" -> "Fat_hen" per
    species = species.replace(' ', '_')

    df = df.append({
        "file": file_,
        "species": species
        }, ignore_index=True)

df.to_csv('PlantClassificationLabels.csv', index=False)