The error that i get while running the program for **Object Detection finetuning**..
Any one if know the solution for this, kindly help me out. More thankful to you..
File "<ipython-input-113-72bac7bde4d7>", line 41, in __getitem__
pos = np.where(masks[i])
TypeError: 'bool' object is not subscriptable
# This where there the problem comes
其中蒙版包含图片的坐标值...
for i in range(num_objs):
pos = np.where(masks[i])
xmin = np.min(pos[1])
xmax = np.max(pos[1])
ymin = np.min(pos[0])
ymax = np.max(pos[0])
boxes.append([xmin, ymin, xmax, ymax])
实际上我不知道如何清除此错误
请执行:
print(type(num_objs))
for i in range(num_objs):
print(type(masks), type(pos))
pos = np.where(masks[i])
xmin = np.min(pos[1])
xmax = np.max(pos[1])
ymin = np.min(pos[0])
ymax = np.max(pos[0])
boxes.append([xmin, ymin, xmax, ymax])
之所以会发生此错误,是因为某些布尔变量的特征是数组。也许要进行初始化,或者使用[index]访问变量。