在复现IJCAI2018_SSDH-master项目时,在我加粗斜体的位置出现报错,在读取最后一张图片时出现错误 list index out of range,应该怎么解决啊??
def img_data(self, index):
if self._status:
return (self._img[index, :], self._label[index, :])
else:
ret_img = []
ret_label = []
for i in index:
if self.train:
if not self._load[i]:
temp_img = imread(self.i_lines[i].strip().split()[0])
temp_img = imresize(temp_img, (224,224))
self._img[i] = temp_img
self._label[i] = [int(j) for j in self.l_lines[i].strip().split()[:]]
self._load[i] = 1
self._load_num += 1
ret_img.append(self._img[i])
ret_label.append(self._label[i])
else:
_ ** self._label[i] = [int(j) for j in self.l_lines[i].strip().split()[:]]**_
temp_img = imread(self.i_lines[i].strip().split()[0])
if temp_img.shape[2]!=3:
temp_img = temp_img[0:3,:,:]
temp_img = np.array(Image.fromarray(temp_img).resize((224,224)))
# temp_img = imresize(temp_img, (224,224))
ret_img.append(temp_img)
ret_label.append([int(j) for j in self.l_lines[i].strip().split()[:]])
if self._load_num == self.n_samples:
self._status = 1
self._img = np.asarray(self._img)
return (ret_img, ret_label)