Skip to content

  • 体验新版
    • 正在加载...
  • 登录
  • PaddlePaddle
  • PaddleHub
  • Issue
  • #922

P
PaddleHub
  • 项目概览

PaddlePaddle / PaddleHub
大约 2 年 前同步成功

通知 285
Star 12117
Fork 2091
  • 代码
    • 文件
    • 提交
    • 分支
    • Tags
    • 贡献者
    • 分支图
    • Diff
  • Issue 200
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 4
  • Wiki 0
    • Wiki
  • 分析
    • 仓库
    • DevOps
  • 项目成员
  • Pages
P
PaddleHub
  • 项目概览
    • 项目概览
    • 详情
    • 发布
  • 仓库
    • 仓库
    • 文件
    • 提交
    • 分支
    • 标签
    • 贡献者
    • 分支图
    • 比较
  • Issue 200
    • Issue 200
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 4
    • 合并请求 4
  • Pages
  • 分析
    • 分析
    • 仓库分析
    • DevOps
  • Wiki 0
    • Wiki
  • 成员
    • 成员
  • 收起侧边栏
  • 动态
  • 分支图
  • 创建新Issue
  • 提交
  • Issue看板
已关闭
开放中
Opened 9月 23, 2020 by saxon_zh@saxon_zhGuest

模型chinese_text_detection_db_mobile在C++下预测报错

Created by: ylj135cool

PaddlePaddle:1.8.4 PaddleHub:1.8.2 模型:chinese_text_detection_db_mobile=1.0.3 系统:win10 编译环境:VS2019

问题描述: 使用C++部署方式,按照文档提示,测试PaddleHub中的文字检测模型“chinese_text_detection_db_mobile”时,在预测时报错。

报错内容如下:

`--------------------------------------------
C++ Call Stacks (More useful to developers):
--------------------------------------------
Windows not support stack backtrace yet.

----------------------
Error Message Summary:
----------------------
InvalidArgumentError: Broadcast dimension mismatch. Operands could not be broadcast together with the shape of X = [1, 96, 12, 40] and the shape of Y = [1, 96, 11, 40]. Received [12] in X is not equal to [11] in Y at i:2.
  [Hint: Expected x_dims_array[i] == y_dims_array[i] || x_dims_array[i] <= 1 || y_dims_array[i] <= 1 == true, but received x_dims_array[i] == y_dims_array[i] || x_dims_array[i] <= 1 || y_dims_array[i] <= 1:0 != true:1.] at (D:\1.8.2\paddle\paddle/fluid/operators/elementwise/elementwise_op_function.h:157)`

实际的调用代码如下:

        void Pridict(cv::Mat& mat)
        {
            int batch_size = 1;
            int channels = mat.channels();
            int height = mat.rows;
            int width = mat.cols;
            int nums = batch_size * channels * height * width;

            float* input = new float[nums] {0};
            cv::Mat newMat;
            mat.convertTo(newMat, CV_32FC3);

            // data format NHWC to NCHW
            int idx = 0;
            for (int i = 0; i < batch_size; ++i)
            {
                int offsetBatch = i * width * height * channels;
                for (int j = 0; j < height; ++j)
                {
                    for (int k = 0; k < width; ++k)
                    {
                        auto data = newMat.at<cv::Vec3f>(j, k);
                        int offset = j * width + k;
                        input[offsetBatch + offset] = data[0];
                        input[offsetBatch + width * height + offset] = data[1];
                        input[offsetBatch + width * height * 2 + offset] = data[2];
                    }
                }
            }
            //for (int i = 0; i < channels; ++i) {
            //    cv::extractChannel(newMat, cv::Mat(height, width, CV_32FC1, input + i * height * width), i);
            //}
            auto input_names = predictor->GetInputNames();
            auto input_t = predictor->GetInputTensor(input_names[0]);
            input_t->Reshape({ batch_size, channels, height, width });
            input_t->copy_from_cpu(input);

            //此处执行后报错
            predictor->ZeroCopyRun();

            std::vector<float> out_data;
            auto output_names = predictor->GetOutputNames();
            auto output_t = predictor->GetOutputTensor(output_names[0]);
            std::vector<int> output_shape = output_t->shape();
            int out_num = std::accumulate(output_shape.begin(), output_shape.end(), 1,
                std::multiplies<int>());

            out_data.resize(out_num);
            output_t->copy_to_cpu(out_data.data());
            delete[] input;
        }

其中mat是直接从文件加载的一个jpg文件,又遇到类似情况的没有?还请各位大佬指导一下是什么原因,如何解决? 谢谢大家。

指派人
分配到
无
里程碑
无
分配里程碑
工时统计
无
截止日期
无
标识: paddlepaddle/PaddleHub#922
渝ICP备2023009037号

京公网安备11010502055752号

网络110报警服务 Powered by GitLab CE v13.7
开源知识
Git 入门 Pro Git 电子书 在线学 Git
Markdown 基础入门 IT 技术知识开源图谱
帮助
使用手册 反馈建议 博客
《GitCode 隐私声明》 《GitCode 服务条款》 关于GitCode
Powered by GitLab CE v13.7