Skip to content

update inference scripts #15043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

zhang-prog
Copy link
Contributor

No description provided.

Copy link

paddle-bot bot commented Apr 18, 2025

Thanks for your contribution!

@GreatV GreatV requested a review from Copilot April 19, 2025 08:58
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates multiple inference scripts to incorporate TensorRT conversion logic and YAML configuration support while revising file selection for model loading across Python and C++ modules. Key changes include:

  • Adding YAML-based configuration loading and TensorRT conversion in utility.py.
  • Adjustments in prediction and model loading logic in predict_rec.py and ocr_rec.cpp.
  • Updating the C++ header to incorporate YAML and improve label file handling.

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

File Description
tools/infer/utility.py Added YAML import, TensorRT conversion helper functions, and config update logic.
tools/infer/predict_rec.py Revised TextRecognizer initialization to load and process YAML config.
deploy/cpp_infer/src/ocr_rec.cpp Changed model file selection logic to prefer inference.json if available.
deploy/cpp_infer/include/ocr_rec.h Updated header includes and modified label file reading with YAML config.
Files not reviewed (1)
  • deploy/cpp_infer/CMakeLists.txt: Language not supported
Comments suppressed due to low confidence (1)

tools/infer/utility.py:293

  • The variable 'file_name' is used here but not defined in this scope; consider using a defined identifier or passing it as a parameter.
trt_save_path = f"{model_dir}/.cache/trt/{file_name}"

this->label_list_ = Utility::ReadDict(label_path);
std::string new_label_path = label_path;
std::string yaml_file_path = model_dir + "/inference.yml";
std::ifstream yaml_file(label_path);
Copy link
Preview

Copilot AI Apr 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears the YAML file is intended to be loaded using 'yaml_file_path' (constructed as model_dir + "/inference.yml") rather than 'label_path'; switching to 'yaml_file(yaml_file_path)' should correctly open the intended config file.

Suggested change
std::ifstream yaml_file(label_path);
std::ifstream yaml_file(yaml_file_path);

Copilot uses AI. Check for mistakes.

@zhang-prog zhang-prog force-pushed the feat/inference_scripts branch from 4668c81 to be61c7c Compare April 28, 2025 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant