I have been trying to save images from a column consisting of image urls in my dataframe into Train and Validation folders in google drive. Now this code is disregarding the where statement and putting all 1560 images into both the folders.
df1 dataframe Number of train and validation images
def url_to_png(i, url, file_path):
filename = '{}{}image{}.png'.format(df1['Patient Number'][i], df1['Abnormality'][i],i)
full_path = '{}{}'.format(file_path, filename)
urllib.request.urlretrieve(url, full_path)
#print('{} saved.'.format(filename))
return None
FILEPATH1 = path + 'Images/Train/'
FILEPATH2 = path + 'Images/Validation/'
urls = df1["Bone Image"]
for i, url in enumerate(urls.values):
np.where(df1.loc[df1['Dataset Assigned'] == 'Validation'], url_to_png(i, url, FILEPATH2), url_to_png(i, url, FILEPATH1))
I have tried using if-else statement too, but didn't work. Please help me resolve this issue.
Aucun commentaire:
Enregistrer un commentaire