这个错误是因为在读取数据目录时,误将标签文件(lables.txt)也读进来了,导致在处理文件名时出现了错误。解决方法是在读取文件名之前,先将标签文件过滤掉。可以使用类似以下代码:

for filename in os.listdir(data_dir):
    if filename == 'lables.txt':  # 跳过标签文件
        continue
    age = int(filename.split('_')[0])
    ...
---------------------------------------------------------------------------ValueError Traceback most recent call lastipython-input-3-1e723b2ec452 in module 20 2

原文地址: https://www.cveoy.top/t/topic/e0Yg 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录