Git Product home page Git Product logo

Comments (2)

GreatV avatar GreatV commented on July 18, 2024

麻烦提供一个最小可复现的demo

from paddleocr.

hangLt333 avatar hangLt333 commented on July 18, 2024

麻烦提供一个最小可复现的demo

什么样的demo 不用代码吗
我是只修改了 args.cpp里打开GPU 和TensorRT ,打开det和rec
然后调用一次ocrInit,然后反复调用ocr_once 实现的 能这样用吗

PPOCR *ocrRun;
//OCR初始化
void ocrInit(int argc, char **argv)
{
  google::ParseCommandLineFlags(&argc, &argv, true);
  check_params(); //检测ocr配置
  ocrRun = new PPOCR();
}
//OCR一次
int ocr_once (cv::Mat ocrimg , Ui::MainWindow *ui)
{

  if (ocrimg.empty()) {
    std::cerr << "[ERROR] image inexistence! "
              << std::endl;
    return 0;
   // exit(1);
  }

  if (!Utility::PathExists(FLAGS_output)) {
    Utility::CreateDir(FLAGS_output);
  }
  if (FLAGS_type == "ocr") {
    std::vector<OCRPredictResult> ocr_results =
          ocrRun->ocr(ocrimg, FLAGS_det, FLAGS_rec, FLAGS_cls); //*OCR

    Utility::print_result(ocr_results);         //printf
    //print_result_recUi(ocr_results ,ui);


    if (FLAGS_visualize && FLAGS_det) {

      cv::Mat srcimg = ocrimg;
      QDateTime current_date_time =QDateTime::currentDateTime();
      std::string current_date_name = (QString("%1-%2-%3-%4-%5-%6").arg(current_date_time.date().year()).arg(current_date_time.date().month())
                                          .arg(current_date_time.date().day()).arg(current_date_time.time().hour())
                                          .arg(current_date_time.time().minute()).arg(current_date_time.time().msec())).toStdString();

      Utility::VisualizeBboxes(srcimg, ocr_results,     //画框 并 保存
                               FLAGS_output + "/" + current_date_name + ".jpg");

      return 1;
    }
  }
  return 0;
}

初始化后输出内容是这样的

In PP-OCRv3, rec_image_shape parameter defaults to '3, 48, 320',if you are using recognition model with PP-OCRv2 or an older version, please set --rec_image_shape='3,32,320
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0606 13:33:05.597819 10352 analysis_config.cc:1539] In CollectShapeInfo mode, we will disable optimizations and collect the shape information of all intermediate tensors in the compute graph and calculate the min_shape, max_shape and opt_shape.
I0606 13:33:06.436725 10352 analysis_predictor.cc:1532] TensorRT subgraph engine is enabled
I0606 13:33:06.436725 10352 analysis_predictor.cc:1740] Ir optimization is turned off, no ir pass will be executed.
e[1me[35m--- Running analysis [ir_graph_build_pass]e[0m
I0606 13:33:06.440716 10352 executor.cc:187] Old Executor is Running.
e[1me[35m--- Running analysis [ir_analysis_pass]e[0m
e[1me[35m--- Running analysis [save_optimized_model_pass]e[0m
e[1me[35m--- Running analysis [ir_params_sync_among_devices_pass]e[0m
I0606 13:33:06.454707 10352 ir_params_sync_among_devices_pass.cc:53] Sync params from CPU to GPU
e[1me[35m--- Running analysis [adjust_cudnn_workspace_size_pass]e[0m
e[1me[35m--- Running analysis [inference_op_replace_pass]e[0m
e[1me[35m--- Running analysis [memory_optimize_pass]e[0m
I0606 13:33:06.468638 10352 memory_optimize_pass.cc:118] The persistable params in main graph are : 4.47025MB
I0606 13:33:06.474623 10352 memory_optimize_pass.cc:246] Cluster name : tmp_85  size: 1536
I0606 13:33:06.474623 10352 memory_optimize_pass.cc:246] Cluster name : tmp_21  size: 192
I0606 13:33:06.474623 10352 memory_optimize_pass.cc:246] Cluster name : tmp_94  size: 1536
I0606 13:33:06.474623 10352 memory_optimize_pass.cc:246] Cluster name : tmp_118  size: 96
I0606 13:33:06.474623 10352 memory_optimize_pass.cc:246] Cluster name : relu_1.tmp_0  size: 384
I0606 13:33:06.474623 10352 memory_optimize_pass.cc:246] Cluster name : hardswish_79.tmp_0  size: 1536
I0606 13:33:06.474623 10352 memory_optimize_pass.cc:246] Cluster name : tmp_35  size: 384
I0606 13:33:06.474623 10352 memory_optimize_pass.cc:246] Cluster name : tmp_73  size: 768
I0606 13:33:06.474623 10352 memory_optimize_pass.cc:246] Cluster name : x  size: 12
e[1me[35m--- Running analysis [ir_graph_to_program_pass]e[0m
I0606 13:33:06.519503 10352 analysis_predictor.cc:1838] ======= optimize end =======
I0606 13:33:06.520501 10352 naive_executor.cc:200] ---  skip [feed], feed -> x
I0606 13:33:06.522496 10352 naive_executor.cc:200] ---  skip [sigmoid_0.tmp_0], fetch -> fetch
In PP-OCRv3, default rec_img_h is 48,if you use other model, you should set the param rec_img_h=32
I0606 13:33:06.523494 10352 analysis_config.cc:1539] In CollectShapeInfo mode, we will disable optimizations and collect the shape information of all intermediate tensors in the compute graph and calculate the min_shape, max_shape and opt_shape.
I0606 13:33:06.530472 10352 analysis_predictor.cc:1740] Ir optimization is turned off, no ir pass will be executed.
e[1me[35m--- Running analysis [ir_graph_build_pass]e[0m
e[1me[35m--- Running analysis [ir_analysis_pass]e[0m
e[1me[35m--- Running analysis [save_optimized_model_pass]e[0m
e[1me[35m--- Running analysis [ir_params_sync_among_devices_pass]e[0m
I0606 13:33:06.554409 10352 ir_params_sync_among_devices_pass.cc:53] Sync params from CPU to GPU
e[1me[35m--- Running analysis [adjust_cudnn_workspace_size_pass]e[0m
e[1me[35m--- Running analysis [inference_op_replace_pass]e[0m
e[1me[35m--- Running analysis [memory_optimize_pass]e[0m
I0606 13:33:06.578346 10352 memory_optimize_pass.cc:118] The persistable params in main graph are : 10.2689MB
I0606 13:33:06.584360 10352 memory_optimize_pass.cc:246] Cluster name : linear_170.tmp_1  size: 26500
I0606 13:33:06.584360 10352 memory_optimize_pass.cc:246] Cluster name : shape_5.tmp_0_slice_1  size: 4
I0606 13:33:06.584360 10352 memory_optimize_pass.cc:246] Cluster name : conv2d_198.tmp_1  size: 11520
I0606 13:33:06.584360 10352 memory_optimize_pass.cc:246] Cluster name : linear_170.tmp_0  size: 26500
I0606 13:33:06.584360 10352 memory_optimize_pass.cc:246] Cluster name : pool2d_3.tmp_0_clone_0  size: 1920
I0606 13:33:06.584360 10352 memory_optimize_pass.cc:246] Cluster name : batch_norm_5.tmp_0  size: 1920
I0606 13:33:06.584360 10352 memory_optimize_pass.cc:246] Cluster name : x  size: 576
I0606 13:33:06.584360 10352 memory_optimize_pass.cc:246] Cluster name : transpose_44.tmp_0_slice_2  size: 480
I0606 13:33:06.584360 10352 memory_optimize_pass.cc:246] Cluster name : fill_constant_17.tmp_0  size: 4
I0606 13:33:06.584360 10352 memory_optimize_pass.cc:246] Cluster name : fill_constant_19.tmp_0  size: 4
I0606 13:33:06.584360 10352 memory_optimize_pass.cc:246] Cluster name : shape_3.tmp_0_slice_1  size: 4
I0606 13:33:06.584360 10352 memory_optimize_pass.cc:246] Cluster name : reshape2_27.tmp_1  size: 0
e[1me[35m--- Running analysis [ir_graph_to_program_pass]e[0m
I0606 13:33:06.629241 10352 analysis_predictor.cc:1838] ======= optimize end =======
I0606 13:33:06.629241 10352 naive_executor.cc:200] ---  skip [feed], feed -> x
I0606 13:33:06.631232 10352 naive_executor.cc:200] ---  skip [softmax_11.tmp_0], fetch -> fetch

from paddleocr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.