imagepaths = []
# Go through all the files and subdirectories inside a folder and save path to images inside list
for root, dirs, files in os.walk(".", topdown=False):
for name in files:
path = os.path.join(root, name)
if path.endswith("png"): # We want only the images
imagepaths.append(path)
X = [] # Image data
y = [] # Labels
# Loops through imagepaths to load images and labels into arrays
for path in imagepaths:
img = cv2.imread(path) # Reads image and returns np.array
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # Converts into the corret colorspace (GRAY)
img = cv2.resize(img, (320, 120)) # Reduce image size so training can be faster
X.append(img)
# Processing label in image path,
category = path.split("/")[3]
label = int(category.split("_")[0][1]) # We need to convert 10_down to 00_down, or else it crashes
y.append(label)
Я сталкиваюсь с ошибкой при разделении, фактически извлекаю изображение из папки 10_down и преобразовываю его в 00_down, как решить эту проблему. Я не получаю