meituan / YOLOv6

YOLOv6: a single-stage object detection framework dedicated to industrial applications.
GNU General Public License v3.0
5.72k stars 1.03k forks source link

RuntimeError: Calibrator returned None. #520

Closed wanyne-yyds closed 2 years ago

wanyne-yyds commented 2 years ago
W0929 11:35:26.753783 140630321796544 tensor_quantizer.py:237] Load calibrated amax, shape=torch.Size([]).
neck.downsample2.conv._input_quantizer  : TensorQuantizer(8bit narrow fake per-tensor amax=15.5406 calibrator=HistogramCalibrator scale=1.0 quant)
W0929 11:35:26.754141 140630321796544 tensor_quantizer.py:237] Load calibrated amax, shape=torch.Size([64, 1, 1, 1]).
neck.downsample2.conv._weight_quantizer : TensorQuantizer(8bit narrow fake axis=0 amax=[0.0419, 0.2482](64) calibrator=MaxCalibrator scale=1.0 quant)
W0929 11:35:36.505044 140630321796544 tensor_quantizer.py:237] Load calibrated amax, shape=torch.Size([]).
neck.downsample1.conv._input_quantizer  : TensorQuantizer(8bit narrow fake per-tensor amax=15.7757 calibrator=HistogramCalibrator scale=1.0 quant)
W0929 11:35:36.505725 140630321796544 tensor_quantizer.py:237] Load calibrated amax, shape=torch.Size([128, 1, 1, 1]).
neck.downsample1.conv._weight_quantizer : TensorQuantizer(8bit narrow fake axis=0 amax=[0.0268, 0.1293](128) calibrator=MaxCalibrator scale=1.0 quant)
Traceback (most recent call last):
  File "./tools/partial_quantization/sensitivity_analyse.py", line 115, in <module>
    model_ptq= do_ptq(model, train_loader, args.batch_number, device)
  File "/home/ckn/Code/YOLOv6/tools/partial_quantization/ptq.py", line 138, in do_ptq
    compute_amax(model_ptq, method='entropy')
  File "/home/ckn/Code/YOLOv6/tools/partial_quantization/ptq.py", line 49, in compute_amax
    module.load_calib_amax(**kwargs)
  File "/home/ckn/.local/lib/python3.6/site-packages/pytorch_quantization/nn/modules/tensor_quantizer.py", line 236, in load_calib_amax
    raise RuntimeError(err_msg)
RuntimeError: Calibrator returned None.

我用自己的数据集训练了一个YOLOv6s的模型,然后想尝试使用部分量化去量化这个模型,就报了如上错误,请问要怎么解决? 使用的命令如下:

python ./tools/partial_quantization/sensitivity_analyse.py \
--weights /home/ckn/Code/YOLOv6/runs/train/Test_2022_09_27_16_01_24/weights/best_ckpt.pt \
--batch-size 32 \
--batch-number 4 \
--data-root /data_ssd/ckn_ssd/Data_trainset/YOLOv6-CocoAndYOLOFormat-HOD-220914/images/train2017 \
--data-yaml /home/ckn/Code/YOLOv6/data/dataset.yaml
Chilicyy commented 2 years ago

@wanyne-yyds 你好,这个问题已经修复,麻烦拉取最新的代码试试。

wanyne-yyds commented 2 years ago

拉取最新代码解决问题