Skip to content
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

Enable openvino deployment #91

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

Conversation

sungchul2
Copy link

@sungchul2 sungchul2 commented Aug 28, 2024

This PR includes:

  • Enable validation with deployed models to onnx and openvino (trt and deploy are not tested.)
    $ python yolo/lazy.py \
        task=validation \
        name=AnyNameYouWant \ # AnyNameYouWant
        device=cpu \ # hardware cuda, cpu, mps
        model=v9-c \ # model version: v9-c, m, s
        task.fast_inference=onnx # onnx, openvino, trt, deploy
    • Save deployed models into weights/ instead of root
      weights
      ├── v9-c.bin
      ├── v9-c.onnx
      ├── v9-c.pt
      └── v9-c.xml
  • Enable openvino deployment
    • To deploy the model to openvino
    $ pip install openvino
    $ python yolo/lazy.py task=validation model=v9-c device=cpu task.fast_inference=openvino
    ...
    [08/28 12:50:24] WARNING | __ Error loading OpenVINO model: Exception from src/inference/src/cpp/core.cpp:90:
    Check 'util::directory_exists(path) || util::file_exists(path)' failed at src/frontends/common/src/frontend.cpp:113:
    FrontEnd API failed with GeneralFailure
    ir: Could not open the file: "weights/v9-c.xml"
                                                                                                                                                                                                                                                                                                                            
    [08/28 12:50:26]   INFO  | 📥 OpenVINO model saved to weights/v9-c.xml
    ...
    
    # for fp16 compression
    $ python yolo/lazy.py task=validation model=v9-c device=cpu task.fast_inference=openvino task.precision=FP16
    ...
    [08/28 12:59:35] WARNING | __ Error loading OpenVINO model: Exception from src/inference/src/cpp/core.cpp:90:
    Check 'util::directory_exists(path) || util::file_exists(path)' failed at src/frontends/common/src/frontend.cpp:113:
    FrontEnd API failed with GeneralFailure:
    ir: Could not open the file: "weights/v9-c_fp16.xml"
    
    [08/28 12:59:37]   INFO  | 📥 OpenVINO model saved to weights/v9-c_fp16.xml
    ...
  • Enable post-training quantization using nncf
    $ pip install nncf
    $ python yolo/lazy.py task=validation model=v9-c device=cpu task.fast_inference=openvino task.ptq=True # ptq to uint8
    ...
    [08/28 10:25:00]   INFO  | 🚀 Using OpenVINO as MODEL frameworks!
    INFO:nncf:NNCF initialized successfully. Supported frameworks detected: torch, onnx, openvino
    ...
    Statistics collection _____________________________________________________________________________________________________ 100% 300/300 _ 0:24:38 _ 0:00:00
    Applying Fast Bias correction _____________________________________________________________________________________________ 100% 291/291 _ 0:00:37 _ 0:00:00
    ...

TODO:

  • Direct OpenVINO IR conversion without ONNX model

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