顺便看了各个版本的dbnet。
可以研究pytorch模型如何转libtorch模型,如何转onnx模型,如何转tensorrt模型等。
下面会随时记录一些会遇到的问题。
1、https://github.com/WenmuZhou/PytorchOCR/blob/master/tools/det_infer.py
这个里面在推理前应该加上不计算梯度,否则会报显存不够的错误如下:
RuntimeError: CUDA out of memory. Tried to allocate 138.00 MiB (GPU 0; 11.00 GiB total capacity; 8.08 GiB already allocated; 114.32 MiB free; 8.63 GiB reserved in total by PyTorch)
应该将49行:
out = self.model(tensor)
改为:
with torch.no_grad():
out = self.model(tensor)