Created
July 12, 2021 15:35
-
-
Save RishiRajak/880280299f75629bcf0d4920d7e0fe19 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
#Function that can build a dataframe on passing folderpath. | |
def getdata(folder_path): | |
sig = pd.DataFrame(columns=['image_abs_path','image_labels']) | |
for key,value in labelnames.items(): | |
#print("processing for label: {}".format(label)) | |
label_i = folder_path+"/"+str(key) | |
#read directory | |
dirs_label_i = os.listdir(label_i) | |
idx = 0 | |
for image in dirs_label_i: | |
#create a absolute image path | |
sig_i = os.path.join(label_i,image) | |
#print('Absolute path for image no. {} and label {}: {}'\ | |
#.format(idx,label,flower_i)) | |
#fill the dataframe with path and label | |
sig = sig.append({'image_abs_path':sig_i, | |
'image_labels':key}, | |
ignore_index=True) | |
idx += 1 | |
return sig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment