使用mobile分类、检测、预测模型结果错乱
收藏
使用ch_ppocr_mobile_v2.0_cls_opt.nb、ch_ppocr_mobile_v2.0_det_opt.nb、ch_ppocr_mobile_v2.0_rec_opt.nb模型预测出来结果与ppocr_keys_v1.txt里面数据对比,完全不对照。使用的paddlelite版本为2.9;希望答复下ppocr_keys_v1.txt是每个版本对应一个模型还是一共就一个
0
收藏
请登录后评论
是不是预处理的问题呢
就是不知道是哪个环节出了问题,预处理方式是参考了安卓。
帖部分代码,看下是不是有问题:
cv::Mat image;
UIImageToMat(self.image, image);
std::vector ratio_hw;
float ratio_h{};
float ratio_w{};
cv::Mat img_cat;
image.copyTo(img_cat);
img_cat = resize_img_type0(img_cat, 960, &ratio_h, &ratio_w);
if (4 == img_cat.channels()) {
cv::cvtColor(img_cat, img_cat, COLOR_RGBA2BGR);
}
normalize_op(&img_cat, mean, scale, true);
std::vector input(1 * 3 * img_cat.rows * img_cat.cols, 0.0f);
permute_run(&img_cat, input.data());
std::vector results = orc_predictor->infer_ocr({1,3,img_cat.rows,img_cat.cols}, input.data(), img_cat.rows*img_cat.cols, NET_OCR, image);
void permute_run(const cv::Mat *im, float *data) {
int rh = im->rows;
int rw = im->cols;
int rc = im->channels();
if(3 < rc) rc=3;
for (int i = 0; i < rc; ++i) {
cv::Mat _mat = cv::Mat(rh, rw, CV_32FC1, data + i * rh * rw);
cv::extractChannel(*im, _mat, i);
}
}
和demo对比下,不行先替换部分数据试试