列表索引超出范围 _ UNET

list index out of range _ UNET

如能帮我解决问题,将不胜感激

import matplotlib.pyplot as plt
import tifffile as tiff
import os
    
rows = 3
cols = 4
axes=[]
fig=plt.figure(figsize=[10,10])
i=["/images/1","/masks/1","/images/2","/masks/2"]
i=i+["/images/3","/masks/3","/images/4","/masks/4"]
p=1
m=0
for a in range(rows*cols):
  if i[m].find("masks")!=-1:
    b = plt.imread("/content/drive/MyDrive/PFE_MOHTICH/dataset/data/test{}.png".format(str(i[m])))
  else:
    b = tiff.imread("/content/drive/MyDrive/PFE_MOHTICH/dataset/data/test{}.tiff".format(str(i[m])))
  m=m+1
  axes.append( fig.add_subplot(rows, cols, a+1) )
  plt.imshow(b)
  plt.savefig("ex_val.png",cmap='binary_r')
  fig.tight_layout()    
  plt.show()

导致错误的行

(if i[m].find("masks")!=-1) :

错误信息:

list index out of range

不知道这有什么难看的。您的 for 循环

for a in range(rows*cols): #rows*cols = (3*4) = 12
# In this loop you update m every iteration
  m = m+1

所以你的 m 从 011 而你的 i 只有 8 个元素。
比如什么是你不能 see/get?