susan19900316 / yolov5_tensorrt_int8 Goto Github PK
View Code? Open in Web Editor NEWyolov5 tensorrt int8量化方法汇总
yolov5 tensorrt int8量化方法汇总
如题
在yolov5缺少End2End库,导致pytorch_yolov5_ptq.py 文件中from models.experimental import End2End失败
这是怎么回事啊
请问QAT量化部分的代码和train.py一样,是如何进行量化的呀
I0312 11:07:43.887332 140542321780544 tensor_quantizer.py:180] Enable MaxCalibrator Enable MaxCalibrator I0312 11:07:43.887368 140542321780544 tensor_quantizer.py:184] Disable
quantstage. Disable
quantstage. I0312 11:07:43.887401 140542321780544 tensor_quantizer.py:180] Enable MaxCalibrator Enable MaxCalibrator I0312 11:07:43.887435 140542321780544 tensor_quantizer.py:184] Disable
quantstage. Disable
quantstage. I0312 11:07:43.887468 140542321780544 tensor_quantizer.py:180] Enable MaxCalibrator Enable MaxCalibrator I0312 11:07:43.887503 140542321780544 tensor_quantizer.py:184] Disable
quantstage. Disable
quantstage. I0312 11:07:43.887536 140542321780544 tensor_quantizer.py:180] Enable MaxCalibrator Enable MaxCalibrator I0312 11:07:43.887570 140542321780544 tensor_quantizer.py:184] Disable
quantstage. Disable
quantstage. I0312 11:07:43.887603 140542321780544 tensor_quantizer.py:180] Enable MaxCalibrator Enable MaxCalibrator I0312 11:07:43.887638 140542321780544 tensor_quantizer.py:184] Disable
quantstage. Disable
quantstage. I0312 11:07:43.887670 140542321780544 tensor_quantizer.py:180] Enable MaxCalibrator Enable MaxCalibrator I0312 11:07:43.887704 140542321780544 tensor_quantizer.py:184] Disable
quantstage. Disable
quantstage. I0312 11:07:43.887737 140542321780544 tensor_quantizer.py:180] Enable MaxCalibrator Enable MaxCalibrator 0it [00:00, ?it/s] Traceback (most recent call last): File "pytorch_yolov5_ptq.py", line 135, in <module> collect_stats(q_model, dataloader) File "pytorch_yolov5_ptq.py", line 51, in collect_stats for i, image in tqdm(enumerate(data_loader)): File "/root/anaconda3/envs/mjj_py377/lib/python3.7/site-packages/tqdm/std.py", line 1178, in __iter__ for obj in iterable: File "/root/anaconda3/envs/mjj_py377/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 521, in __next__ data = self._next_data() File "/root/anaconda3/envs/mjj_py377/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 561, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "/root/anaconda3/envs/mjj_py377/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 52, in fetch return self.collate_fn(data) File "/root/anaconda3/envs/mjj_py377/lib/python3.7/site-packages/torch/utils/data/_utils/collate.py", line 64, in default_collate return default_collate([torch.as_tensor(b) for b in batch]) File "/root/anaconda3/envs/mjj_py377/lib/python3.7/site-packages/torch/utils/data/_utils/collate.py", line 56, in default_collate return torch.stack(batch, 0, out=out) RuntimeError: stack expects each tensor to be equal size, but got [3, 426, 640] at entry 0 and [3, 640, 615] at entry 1
这个报错我太理解
int8精度损失评估如何像val.py中对FP32和FP16的验证进行操作
def forward(
ctx,
boxes,
scores,
background_class=-1,
box_coding=1,
iou_threshold=0.45,
max_output_boxes=100,
plugin_version="1",
score_activation=0,
score_threshold=0.25,
):
batch_size, num_boxes, num_classes = scores.shape
num_det = torch.randint(0, max_output_boxes, (batch_size, 1), dtype=torch.int32)
det_boxes = torch.randn(batch_size, max_output_boxes, 4)
det_scores = torch.randn(batch_size, max_output_boxes)
det_classes = torch.randint(0, num_classes, (batch_size, max_output_boxes), dtype=torch.int32)
return num_det, det_boxes, det_scores, det_classes
使用官方 yolov5s.onnx
运行 python onnx2trt_ptq.py
出现
engine = builder.build_engine(network,config)
Segmentation fault (core dumped)
错误
我安装了pytorch-quantization后,执行
python pytorch_yolov5_qat.py --weights yolov5s.pt --cfg models/yolov5s.yaml --data data/coco.yaml --img 640
会自动下载yolov5n.pt , AMP check也没有通过。
我就改成了yolov5n.pt
python pytorch_yolov5_qat.py --weights yolov5n.pt --cfg models/yolov5n.yaml --data data/coco.yaml --img 640
AMP check 通过了,但是训练并没有开始,进度条不动。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.