出错代码:
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import numpy as np
import MNN
import cv2
if __name__ == "__main__":
image=cv2.imread(r'D:\data\ocr\wanqu\Age-Gender-MXNET-main\aaa.jpg')
image = cv2.resize(image, (64, 64))
# resize to mobile_net tensor size
# image = image.astype(np.float32)
image = image.astype(float)
# image = image - (103.94, 116.78, 123.68)
# image = image * (0.017, 0.017, 0.017)
image = image.transpose((2, 0, 1))
tmp_input = MNN.Tensor((1, 3, 64, 64), MNN.Halide_Type_Float, image, MNN.Tensor_DimensionType_Caffe)
原因 mnn需要数据类型为float32,float类型就会报错。
正确代码:
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import numpy as np
import MNN
import cv2
if __name__ == "__main__&#
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/jacke121/article/details/123723618
内容来源于网络,如有侵权,请联系作者删除!