| 
 | 1 | +# DETR  | 
 | 2 | + | 
 | 3 | +The Pytorch implementation is [facebookresearch/detr](https://github.com/facebookresearch/detr).  | 
 | 4 | + | 
 | 5 | +For details see [End-to-End Object Detection with Transformers](https://ai.facebook.com/research/publications/end-to-end-object-detection-with-transformers).  | 
 | 6 | + | 
 | 7 | +## Test Environment  | 
 | 8 | + | 
 | 9 | +- GTX2080Ti / Ubuntu16.04 / cuda10.2 / cudnn8.0.4 / TensorRT7.2.1 / OpenCV4.2  | 
 | 10 | +- GTX2080Ti / win10 / cuda10.2 / cudnn8.0.4 / TensorRT7.2.1 / OpenCV4.2 / VS2017  | 
 | 11 | + | 
 | 12 | +## How to Run  | 
 | 13 | + | 
 | 14 | +1. generate .wts from pytorch with .pth  | 
 | 15 | + | 
 | 16 | +```  | 
 | 17 | +// git clone https://github.com/facebookresearch/detr.git  | 
 | 18 | +// go to facebookresearch/detr  | 
 | 19 | +// download https://dl.fbaipublicfiles.com/detr/detr-r50-e632da11.pth  | 
 | 20 | +// download https://raw.githubusercontent.com/freedenS/TestImage/main/demo.jpg  | 
 | 21 | +// copy tensorrtx/detr/gen_wts.py and demo.jpg into facebookresearch/detr  | 
 | 22 | +python gen_wts.py  | 
 | 23 | +// a file 'detr.wts' will be generated.  | 
 | 24 | +```  | 
 | 25 | + | 
 | 26 | +2. build tensorrtx/detr and run  | 
 | 27 | + | 
 | 28 | +```  | 
 | 29 | +// put detr.wts into tensorrtx/detr  | 
 | 30 | +// go to tensorrtx/detr  | 
 | 31 | +// update parameters in detr.cpp if your model is trained on custom dataset.The parameters are corresponding to config in detr.  | 
 | 32 | +mkdir build  | 
 | 33 | +cd build  | 
 | 34 | +cmake ..  | 
 | 35 | +make  | 
 | 36 | +sudo ./detr -s [.wts] // serialize model to plan file  | 
 | 37 | +sudo ./detr -d [.engine] [image folder] // deserialize and run inference, the images in [image folder] will be processed  | 
 | 38 | +// For example  | 
 | 39 | +sudo ./detr -s ../detr.wts detr.engine  | 
 | 40 | +sudo ./detr -d detr.engine ../samples  | 
 | 41 | +```  | 
 | 42 | + | 
 | 43 | +3. check the images generated, as follows. _demo.jpg and so on.  | 
 | 44 | + | 
 | 45 | +## NOTE  | 
 | 46 | + | 
 | 47 | +- tensorrt use fixed input size, if the size of your data is different from the engine, you need to adjust your data and the result.  | 
 | 48 | +- image preprocessing with c++ is a little different with python(opencv vs PIL)  | 
 | 49 | + | 
 | 50 | + | 
 | 51 | +## Latency  | 
 | 52 | + | 
 | 53 | +average cost of doInference(in detr.cpp) from second time with batch=1 under the ubuntu environment above  | 
 | 54 | + | 
 | 55 | +|      | fp32    | fp16    | int8 |  | 
 | 56 | +| ---- | ------- | ------- | ---- |  | 
 | 57 | +| R50  | 19.57ms | 9.424ms | TODO |  | 
 | 58 | + | 
0 commit comments