ncnn lprnet推理的时候,最终的结果有异常(-nan)

lbsnaicq  于 4个月前  发布在  其他
关注(0)|答案(7)|浏览(45)

error log | 日志或报错信息 | ログ

输出的结果(1):
ex.extract("46", out);
print(out) 的结果:inf
输出的结果(2):
ncnn::Extractor ex = Net.create_extractor();
ex.input("in0", in);
ncnn::Mat out;
ex.extract("out0", out);
print(out)的结果:
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan

context | 编译/运行环境 | バックグラウンド

ncnn: commit 51ecc33
运行环境:
ubuntu16.04(Intel® Core™ i5-8250U CPU)

how to reproduce | 复现步骤 | 再現方法

  1. https://github.com/sirius-ai/LPRNet_Pytorch/blob/master/weights/Final_LPRNet_model.pth
    2.用pnnx转换成ncnn模型;
    3.执行以下程序
    cv::Mat image = cv::imread("/home/new/Desktop/lprnet/data/test1/京PL3N67.jpg");
    ncnn::Net Net;
    Net.opt.use_vulkan_compute = false;
    int ret = Net.load_param("/home/new/Desktop/lprnet/lprnet.ncnn.param");
    ret = Net.load_model("/home/new/Desktop/lprnet/lprnet.ncnn.bin");
    int inference_height = 24;
    int inference_width = 94;
    ncnn::Mat in = ncnn::Mat::from_pixels_resize(image.data, ncnn::Mat::PIXEL_BGR2RGB, image.cols, image.rows, inference_width,
    inference_height);
const float mean_vals[3] = {127.5, 127.5, 127.5};
const float norm_vals[3] = {0.0078125f,0.0078125f, 0.0078125f};

in.substract_mean_normalize(mean_vals, norm_vals);
ncnn::Extractor ex = Net.create_extractor();
ex.input("in0", in);
ncnn::Mat out;
ex.extract("out0", out);

more | 其他 | その他

测试文件: https://github.com/sirius-ai/LPRNet_Pytorch/tree/master/data/test
已经把模型发送到您的126邮箱里面(刚开始发的QQ邮箱,可能没有收到)

u91tlkcl

u91tlkcl1#

原因是 nn.MaxPool3d 转到 ncnn 没有支持 3d 输入

ilmyapht

ilmyapht3#

尝试最新版本pnnx转模型试试

3pvhb19x

3pvhb19x4#

模型的输出维数是没问题的,但是输出的结果还是-nan,ncnn:4b68e3f9c10d2a57c32c21d1ba2a5ec6ab03f492

unhi4e5o

unhi4e5o5#

请问,问题解决了吗?

qojgxg4l

qojgxg4l6#

同样lprnet的维度输出都正确,但是最后的输出全是-nan

jckbn6z7

jckbn6z77#

替换maxpool3d后,可以正常输出,但是Reduction mean操作后出现inf,也就是f_pow = torch.pow(f, 2),f_mean = torch.mean(f_pow)后pytorch输出正常,ncnn输出为inf

相关问题