AttributeError: 'NoneType' object has no attribute 'shape'

相关代码块如下:

data_path = 'detaset/VOCdevkit/VOC2012/'
sal_path = data_path + 'saliency_map'
def gen_gt(index):
    line = lines[index]
    line = line[:-1]
    fields = line.split()
    name = fields[0]
    
    im_name = im_path + name + '.jpg'
    bg_name = sal_path + name + '.png'

    img = cv2.imread(im_name)
    sal = cv2.imread(bg_name, 0)  # 0表示以灰度图读取 bg_name 图像
    height, width = sal.shape
    gt = np.zeros((21, height, width), dtype=np.float32)
    sal = np.array(sal, dtype=np.float32)

运行报错如下:

Traceback (most recent call last):
  File "gen_labels.py", line 107, in 
    gen_gt(i)
  File "gen_labels.py", line 54, in gen_gt
    height, width = sal.shape
AttributeError: 'NoneType' object has no attribute 'shape'

Process finished with exit code 1

询问各位怎么该噻?

sal变量从哪来的?