-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat:Add NPU support #1419
Merged
Merged
feat:Add NPU support #1419
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add NPU support for memory cleaning and model initialization - Optimize table model initialization and prediction process - Update memory utils to support NPU - Add language parameter for table model
- Update clean_memory function to support both CUDA and NPU devices - Implement get_device function to centralize device selection logic - Modify model initialization and memory cleaning to use the selected device - Update RapidTableModel to support both RapidOCR and PaddleOCR engines
- Add openai package to requirements-docker.txt
- Remove upper version limit for pydantic dependency - This change allows for the use of the latest pydantic version
- Update `clean_memory.py` to use `torch_npu.npu` instead of `torch.npu` - Update `model_utils.py` to use `torch_npu.npu` instead of `torch.npu` - Simplify NPU availability check and bfloat16 support in `pdf_parse_union_core_v2.py`
- Remove use_npu variable initialization - Comment out device assignment and npu check - Comment out use_npu parameter in ModifiedPaddleOCR constructor
…xtraction - Update the logic for inserting spaces between characters- Consider the next character's position instead of the previous one - Adjust the spacing threshold to 25% of the average character width - Ignore spaces at the end of lines to prevent double spaces
- Implement ONNXModelSingleton to manage ONNX models - Modify ModifiedPaddleOCR to use ONNX models on ARM CPUs without CUDA - Update RapidTableModel to use RapidOCR with ONNXRuntime on CPU - Add rapidocr_onnxruntime dependency in setup.py
- Remove logger.info() call for additional_ocr_params to reduce log verbosity
- Add missing 'else' statement in OCR model selection logic - Ensure consistent formatting of 'if' statements for better readability - Remove unnecessary empty line in the 'app.py' file
… code formatting- Remove extra space in conditional statement for character spacing logic - Adjust spacing in trigonometric checks for line direction- Improve overall code readability and consistency
- Add `draw_char_bbox` function to `draw_bbox.py` for drawing character bounding boxes - Integrate `draw_char_bbox` into `common.py` for use in PDF processing pipeline - Include option to draw character bounding boxes in debug mode
- Add section for using NPU acceleration in both English and Chinese README files - Update system requirements to include CANN environment for NPU support - Enhance the "Quick Start" guide with NPU-related information- Modify hardware requirements to specify "Ascend 910b" for NPU acceleration
- Add Dockerfile for global setup with Ubuntu base image - Add Dockerfile for Huawei NPU setup with Ascend base image - Update requirements file structure: - Rename requirements-docker.txt to docker/china/requirements.txt - Add new requirements files for global and Huawei NPU setups - Install necessary packages and dependencies in both Dockerfiles- Set up virtual environment and install Python packages - Download models and configure magic-pdf for both setups
- Update Dockerfiles in china, global, and huawei_npu directories - Improve wget commands by specifying output file names - Update READMEs to reflect new Dockerfile locations
- Update package sources to use Aliyun mirrors for faster downloads - Upgrade pip and install Python packages in virtual environment - Add python3.10-dev package to Huawei NPU Dockerfile - Update requirements file URLs to master branch- Install specific version of torch_npu in Huawei NPU Dockerfile - Update magic-pdf installation method - Improve modelscope installation process - Optimize model download and configuration update steps
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
Motivation
Please describe the motivation of this PR and the goal you want to achieve through this PR.
Modification
Please briefly describe what modification is made in this PR.
BC-breaking (Optional)
Does the modification introduce changes that break the backward compatibility of the downstream repositories?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.
Use cases (Optional)
If this PR introduces a new feature, it is better to list some use cases here and update the documentation.
Checklist
Before PR:
After PR: