def _parse_function(_file1, _file2):
# live
_file1 = _file1.decode('UTF-8')
meta = glob.glob(_file1+'/*.png')
try:
fr = meta[random.randint(0, len(meta) - 1)]
except:
print(_file1, len(meta))
im_name = fr
lm_name = fr[:-3] + 'npy'
#lm_name = fr[:-12] + '.npy'
if os.path.isfile(lm_name):
image = Image.open(im_name)
width, height = image.size
image_li = image.resize((imsize,imsize))
image_li = np.array(image_li,np.float32)
lm_li = np.load(lm_name, allow_pickle=True) / width
lm_li = lm_li[0,:,:]
print('_____________lm_li___________', lm_li.shape)
if np.random.rand() > 0.5:
image_li = cv2.flip(image_li, 1)
lm_li[:,0] = 1 - lm_li[:,0]
# print('________dimenstions of lmli_______', lm_li[lm_reverse_list,:].shape)
lm_li = lm_li[lm_reverse_list,:]
print('_____________lm_name_________', lm_name)我得到了TypeError: /的不受支持的操作数类型:'NoneType‘和行lm_li = np.load(lm_name, allow_pickle=True) / width的'int'。有人能解释一下怎么解决这个问题吗?
发布于 2022-09-26 10:29:00
这意味着您正在尝试将NoneType除以int (宽度)。之所以发生这种情况,是因为np.load(lm_name, allow_pickle=True)没有按您的意愿工作,而是返回None而不是数字。
我建议您再次检查您的np.load(),看看是否可以在函数之外单独加载它。
https://stackoverflow.com/questions/73852706
复制相似问题