对于前4次迭代,在显示错误后进展顺利
我希望将所有图像拆分到文件夹中,而x_train已经具有值id_code和diognosis-> 0,1,2,3,4,所以我想将图像拆分到它们的relavent文件夹中
在第一个4迭代中,它显示了这些错误之后,正确复制了文件,
import glob
image_list = []
for filename in glob.glob('/home/anonymous/Downloads/aptos2019-blindness-detection/train_images/*.png'):
cdirname, basename = os.path.split(filename)
base=basename[:-4]
val=x_train.loc[x_train['id_code'] == base]
dio=val.diagnosis
con=dio.astype(int)
fin=int(con)
print(fin)
if fin==0:
tt='/home/anonymous/Downloads/aptos2019-blindness-detection/train_images/%s.png' % base
shutil.copy(tt,"/home/anonymous/Downloads/aptos2019-blindness-detection/train/0")
elif fin==1:
kk='/home/anonymous/Downloads/aptos2019-blindness-detection/train_images/%s.png' % base
shutil.copy(kk,"/home/anonymous/Downloads/aptos2019-blindness-detection/train/1")
elif fin==2:
kk='/home/anonymous/Downloads/aptos2019-blindness-detection/train_images/%s.png' % base
shutil.copy(kk,"/home/anonymous/Downloads/aptos2019-blindness-detection/train/2")
elif fin==3:
kk='/home/anonymous/Downloads/aptos2019-blindness-detection/train_images/%s.png' % base
shutil.copy(kk,"/home/anonymous/Downloads/aptos2019-blindness-detection/train/3")
elif fin==4:
kk='/home/anonymous/Downloads/aptos2019-blindness-detection/train_images/%s.png' % base
shutil.copy(kk,"/home/anonymous/Downloads/aptos2019-blindness-detection/train/4")
else:
kk='/home/anonymous/Downloads/aptos2019-blindness-detection/train_images/%s.png' % base
shutil.copy(kk,"/home/anonymous/Downloads/aptos2019-blindness-detection/train")````
4
0
1
0
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-113-a26ea4a13368> in <module>
8 dio=val.diagnosis
9 con=dio.astype(int)
---> 10 fin=int(con)
11 print(fin)
12 if fin==0:
~/.local/lib/python3.6/site-packages/pandas/core/series.py in wrapper(self)
91 return converter(self.iloc[0])
92 raise TypeError("cannot convert the series to "
---> 93 "{0}".format(str(converter)))
94
95 wrapper.__name__ = "__{name}__".format(name=converter.__name__)
TypeError: cannot convert the series to <class 'int'>**strong text**