You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note*: We provide an simplified model of yolox to meet vitis operator support, which is winner solution for the Low Power Computer Vision Challenge 2021 (`LPCV2021 <https://github.com/ModelTC/LPCV2021_Winner_Solution>`_). The model is `yolox-lpcv <https://github.com/ModelTC/EOD/blob/main/configs/det/yolox/yolox_fpga.yaml>`_.
- deploy_backend: Choose your deploy backend supported in mqbench.
44
+
- ptq_only: If True, only ptq will be executed. If False, qat will be executed after ptq calibration.
45
+
- extra_qconfig_dict: Choose your quantization config supported in mqbench.
46
+
- leaf_module: Prevent torch.fx tool entering the module.
47
+
- extra_quantizer_dict: Add some qat modules.
48
+
- resume_model: The path to your float pretrained model.
49
+
- tocaffe_friendly: It is recommended to set it to true, which will affect the output onnx model.
50
+
51
+
52
+
**3**. **Resume training during qat.**
53
+
54
+
.. code-block:: python
55
+
56
+
cd eod/scripts
57
+
# just set resume_model in config file to your model, we will do all the rest.
58
+
sh train_quant.sh
59
+
60
+
61
+
**4**. **Evaluate your quantized model.**
62
+
63
+
.. code-block:: python
64
+
65
+
cd eod/scripts
66
+
# set resume_model in config file to your model
67
+
# add -e to train_quant.sh
68
+
sh train_quant.sh
69
+
70
+
71
+
**5**. **Deploy.**
72
+
73
+
.. code-block:: python
74
+
75
+
cd eod/scripts
76
+
# Follow the prompts to set config in quant_deploy.sh.
77
+
sh quant_deploy.sh
78
+
79
+
80
+
81
+
Introduction of EOD-Mqbench Project
82
+
----------------------------------------
83
+
84
+
The training codes start in eod/commands/train.py. The delpoy codes start in eod/commands/quant_deploy.py.
85
+
86
+
When you set the runner type to quant in config file, QuantRunner will be executed in eod/runner/quant_runner.py.
87
+
88
+
1. Firstly, build your float model in self.build_model().
89
+
2. Load your float pretrained model/quantized model in self.load_ckpt().
90
+
3. Use torch.fx to trace your model in self.quantize_model().
91
+
4. Set your optimization and lr scheduler in self.build_trainer().
92
+
5. Ptq and eval in self.calibrate()
93
+
6. Train in self.train()
94
+
95
+
96
+
**Something important:**
97
+
98
+
- Your model should be splited into network and post-processing. Fx should only trace the network.
99
+
- Quantized model should be saved with the key of qat, as shown in self.save(). This will be used in self.resume_model_from_fp() and self.resume_model_from_quant().
100
+
- We disable the ema in qat. If your ckpt has ema state, we will load ema state into model, as shown in self.load_ckpt().
101
+
- Be careful when your quantized model has extra learnable parameters. You can check it in optimizer, such as eod/tasks/det/plugins/yolov5/utils/optimizer_helper.py. Lsq has been checked.
102
+
- When you are going to deploy model, self.model.deploy should be set to True, as shown in eod/apis/quant_deploy.py. This will remove redundant nodes in your model.
0 commit comments