PaddleOCR改进识别推理效果对比【废弃】

代码地址:PaddlePaddle/PaddleOCR
这篇博客请忽略吧,忘了当时实验的具体前因后果了。

1 中文测试

python3 tools/infer/predict_rec.py \
    --image_dir doc/imgs_words/ch \
    --rec_model_dir inference/ch_rec_mv3_crnn \
    --rec_image_shaoe "3, 32, 320" \
    --rec_char_type ch \
    --rec_batch_num 30 \
    --rec_algorithm CRNN \
    --rec_char_dict_path ./ppocr/utils/ppocr_keys_v1.txt

原效果:

Predicts of doc/imgs_words/ch/word_5.jpg:['西湾监管', 0.9652789]
Predicts of doc/imgs_words/ch/word_4.jpg:['实力活力', 0.94463724]
Predicts of doc/imgs_words/ch/word_3.jpg:['电话:15952301928', 0.99584234]
Predicts of doc/imgs_words/ch/word_2.jpg:['汉阳鹦鹉家居建材市场E区25-26号', 0.95212066]
Predicts of doc/imgs_words/ch/word_1.jpg:['韩国小馆', 0.98803014]
Total predict time for 5 images:0.106

改进效果:

Predicts of doc/imgs_words/ch/word_5.jpg:['西湾监管', 0.9652789]
Predicts of doc/imgs_words/ch/word_4.jpg:['实力活力', 0.94463724]
Predicts of doc/imgs_words/ch/word_3.jpg:['电话:15952301928', 0.99584234]
Predicts of doc/imgs_words/ch/word_2.jpg:['汉阳鹦鹉家居建材市场E区25-26号', 0.95212066]
Predicts of doc/imgs_words/ch/word_1.jpg:['韩国小馆', 0.98803014]
Total predict time for 5 images:0.103

2 英文测试

python3 tools/infer/predict_rec.py \
    --image_dir doc/imgs_words_en \
    --rec_model_dir inference/ch_rec_mv3_crnn \
    --rec_image_shaoe "3, 32, 320" \
    --rec_char_type en \
    --rec_batch_num 30 \
    --rec_algorithm CRNN \
    --rec_char_dict_path ./ppocr/utils/ppocr_keys_v1.txt

原效果:

Predicts of doc/imgs_words_en/word_116.png:['QBhon', 0.60810107]
Predicts of doc/imgs_words_en/word_461.png:['烟国', 0.46494332]
Predicts of doc/imgs_words_en/word_52.png:['Fute', 0.6243137]
Predicts of doc/imgs_words_en/word_201.png:['HOUSE', 0.99250346]
Predicts of doc/imgs_words_en/word_401.png:['lna', 0.5072811]
Predicts of doc/imgs_words_en/word_19.png:['SLOW', 0.8475923]
Predicts of doc/imgs_words_en/word_545.png:['佳', 0.08702037]
Predicts of doc/imgs_words_en/word_10.png:['PAIN', 0.9786783]
Predicts of doc/imgs_words_en/word_308.png:['LITTLE', 0.9917827]
Predicts of doc/imgs_words_en/word_336.png:['6OPER', 0.6035349]
Total predict time for 10 images:0.060

改进效果:

Predicts of doc/imgs_words_en/word_116.png:['QBhon', 0.60810107]
Predicts of doc/imgs_words_en/word_461.png:['烟国', 0.46494332]
Predicts of doc/imgs_words_en/word_52.png:['Fute', 0.6243137]
Predicts of doc/imgs_words_en/word_201.png:['HOUSE', 0.99250346]
Predicts of doc/imgs_words_en/word_401.png:['lna', 0.5072811]
Predicts of doc/imgs_words_en/word_19.png:['SLOW', 0.8475923]
Predicts of doc/imgs_words_en/word_545.png:['佳', 0.08702037]
Predicts of doc/imgs_words_en/word_10.png:['PAIN', 0.9786783]
Predicts of doc/imgs_words_en/word_308.png:['LITTLE', 0.9917827]
Predicts of doc/imgs_words_en/word_336.png:['6OPER', 0.6035349]
Total predict time for 10 images:0.060
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论
当然!以下是一个使用PaddleOCR进行文字识别的C++代码示例: ```cpp #include <iostream> #include <vector> #include <chrono> #include <opencv2/opencv.hpp> #include <paddle_api.h> using namespace std::chrono; int main() { // 加载模型 paddle::lite_api::MobileConfig config; config.set_model_from_file("path/to/model"); config.set_threads(1); config.set_power_mode(paddle::lite_api::PowerMode::LITE_POWER_HIGH); paddle::lite_api::MobilePredictor predictor(config); // 读取图像 cv::Mat img = cv::imread("path/to/image"); if (img.empty()) { std::cerr << "Failed to read image!" << std::endl; return -1; } // 图像预处理 cv::Mat input; cv::cvtColor(img, input, cv::COLOR_BGR2RGB); cv::resize(input, input, cv::Size(640, 640), 0, 0, cv::INTER_LINEAR); input.convertTo(input, CV_32FC3, 1.f / 255.f); paddle::lite_api::Tensor input_tensor; input_tensor.Resize({1, 3, input.rows, input.cols}); auto* input_data = input_tensor.mutable_data<float>(); memcpy(input_data, input.ptr<float>(), input.total() * sizeof(float)); // 执行推理 paddle::lite_api::Tensor output_tensor; predictor.Run({input_tensor}, {&output_tensor}); // 解析结果 auto* output_data = output_tensor.data<float>(); int output_size = output_tensor.numel(); std::vector<std::string> texts; for (int i = 0; i < output_size / 2; ++i) { float* data = output_data + i * 2; std::string text = ""; if (data[1] > 0.5) { text = std::to_string(data[0]); } texts.push_back(text); } // 打印结果 for (const auto& text : texts) { std::cout << "Text: " << text << std::endl; } return 0; } ``` 注意,上述代码仅为示例,你需要根据你的具体环境和模型进行适当的修改和配置。此外,你还需要安装相关的依赖项和头文件,并将模型文件和图像路径替换为正确的路径。
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

张欣-男

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值