When running on Windows, the '/' will result in error, int() problem with string.
Workaround is to change '/' to double backslash '\\', specifically:
-
def get_class(img_path):
return int(img_path.split('\\')[-2])
-
root_dir = 'GTSRB_Final_Training_Images\\GTSRB\\Final_Training\\Images\\'
-
all_img_paths = glob.glob(os.path.join(root_dir, '* \\ *.ppm'))
That fixed the int() error.
Coding solution will be:
-
def get_class(img_path):
return int(img_path.split(os.sep)[-2])
-
as is, non issue.
-
all_img_paths = glob.glob(os.path.join(root_dir, os.path.join(' * ', ' *.ppm')))
Thanks.
When running on Windows, the '/' will result in error, int() problem with string.
Workaround is to change '/' to double backslash '\\', specifically:
def get_class(img_path):
return int(img_path.split('\\')[-2])
root_dir = 'GTSRB_Final_Training_Images\\GTSRB\\Final_Training\\Images\\'
all_img_paths = glob.glob(os.path.join(root_dir, '* \\ *.ppm'))
That fixed the int() error.
Coding solution will be:
def get_class(img_path):
return int(img_path.split(os.sep)[-2])
as is, non issue.
all_img_paths = glob.glob(os.path.join(root_dir, os.path.join(' * ', ' *.ppm')))
Thanks.