【发布时间】:2021-10-25 02:16:23
【问题描述】:
可能是一个菜鸟问题,但在运行时使此错误列表索引超出范围。
images = glob.glob('/OwnCollection')
cars = []
notcars = []
all_cars = []
all_notcars = []
for image in images:
if 'non-vehicles' in image:
all_notcars.append(image)
else:
all_cars.append(image)
# Get only 1/5 of the training data to avoid overfitting
for ix, notcar in enumerate(all_notcars):
if ix % 5 == 0:
notcars.append(notcar)
for ix, car in enumerate(all_cars):
if ix % 5 == 0:
cars.append(car)
car_image = mpimg.imread(cars[1])
notcar_image = mpimg.imread(notcars[5])
错误代码
---> 24 car_image = mpimg.imread(cars[1])
25 notcar_image = mpimg.imread(notcars[5])
26
IndexError: list index out of range
文件夹内 有两个文件夹名为“non-vehicles”,第二个文件夹名为“vehicles”
非常感谢任何帮助。
【问题讨论】:
标签: python-3.x tensorflow logic