Created
July 13, 2021 05:03
-
-
Save Akash-Rawat/d67bc1cce20694831f21ea49326e1ada to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def load_data(): | |
datasets = ['Pedestrian-Detection/Train/Train', 'Pedestrian-Detection/Test/Test', 'Pedestrian-Detection/Val/Val'] | |
output = [] | |
for dataset in datasets: | |
imags = [] | |
labels = [] | |
directoryA = dataset +"/Annotations" | |
directoryIMG = dataset +"/JPEGImages/" | |
file = os.listdir(directoryA) | |
img = os.listdir(directoryIMG) | |
file.sort() | |
img.sort() | |
i = 0 | |
for xml in file: | |
xmlf = os.path.join(directoryA,xml) | |
dom = ElementTree.parse(xmlf) | |
vb = dom.findall('object') | |
label = vb[0].find('name').text | |
labels.append(class_names_label[label]) | |
img_path = directoryIMG + img[i] | |
curr_img = cv2.imread(img_path) | |
curr_img = cv2.resize(curr_img, size) | |
imags.append(curr_img) | |
i +=1 | |
imags = np.array(imags, dtype='float32') | |
imags = imags / 255 | |
labels = np.array(labels, dtype='int32') | |
output.append((imags, labels)) | |
return output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment