Hey guys i want to ask if someone know how to edit my code.
I need to get the path to every folder contains of images.
inside folder images is folder train and test. They have also some folders for example 01,02,03 and iside them is my images
My code is able to get only one subfolder
import numpy as np
import cv2
import os
debug=False
num_classes = 5
input_shape=(480,360,3)
X_train=[]
X_test=[]
Y_train=[]
Y_test=[]
dir='C:\\Users\\Michal\\data\\DB480maj\\images'
i=0
print('constants DONE')
for c in range(0, num_classes):
dir_path=dir+'\\Train\\'+'01'.format(c)+'\\'
file_list=os.listdir(dir_path)
for f in file_list:
path=dir+'\\Train\\'+'01'.format(c)+'\\'+f
raw = cv2.imread(path)
if raw is None:
print(path)
continue
img = np.float32(cv2.resize(raw, (input_shape[0], input_shape[0])))/255
X_train.append(img)
temp=np.zeros(num_classes)
temp[c]=1
Y_train.append(temp)
print('train dataset DONE')