Solved by AndreasW in post #2 
              
              
                why you are split with (’’) 
with 
filename = image_path.split(’’)[-1][:-len(".jpg")] 
you get --> ./dataset/train/32 
and not with (’/)’ 
filename = image_path.split(’/’)[-1][:-len(".jpg")]