Based on the output it seems that the working iterations are creating the label initially as a str and in the conditions are replacing it with an int:
        print("data_path label",type(label)) #label type : str
        if label.startswith("Black"):
            label=0
        elif label.startswith("White"):
            label=1
        elif label.startswith("Brown"):
            label=2

However, the breaking case seems to fall through the condition (no condition returns True) and thus the label stays as a str type and raises the error in the test loop.
In that case, you should check why no condition is met and if you would need to define a default else branch in the __getitem__ method.