├── .gitignore ├── .vscode ├── c_cpp_properties.json ├── launch.json ├── settings.json └── tasks.json ├── CMakeLists.txt ├── LICENSE ├── Makefile ├── README.md ├── example-hard-decode-pybind ├── .vscode │ ├── c_cpp_properties.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── Makefile ├── cuvid-include │ ├── cuviddec.h │ ├── nvEncodeAPI.h │ └── nvcuvid.h ├── ffmpeg │ ├── include │ │ ├── libavcodec │ │ │ ├── ac3_parser.h │ │ │ ├── adts_parser.h │ │ │ ├── avcodec.h │ │ │ ├── avdct.h │ │ │ ├── avfft.h │ │ │ ├── d3d11va.h │ │ │ ├── dirac.h │ │ │ ├── dv_profile.h │ │ │ ├── dxva2.h │ │ │ ├── jni.h │ │ │ ├── mediacodec.h │ │ │ ├── qsv.h │ │ │ ├── vaapi.h │ │ │ ├── vdpau.h │ │ │ ├── version.h │ │ │ ├── videotoolbox.h │ │ │ ├── vorbis_parser.h │ │ │ └── xvmc.h │ │ ├── libavdevice │ │ │ ├── avdevice.h │ │ │ └── version.h │ │ ├── libavfilter │ │ │ ├── avfilter.h │ │ │ ├── buffersink.h │ │ │ ├── buffersrc.h │ │ │ └── version.h │ │ ├── libavformat │ │ │ ├── avformat.h │ │ │ ├── avio.h │ │ │ └── version.h │ │ ├── libavresample │ │ │ ├── avresample.h │ │ │ └── version.h │ │ ├── libavutil │ │ │ ├── adler32.h │ │ │ ├── aes.h │ │ │ ├── aes_ctr.h │ │ │ ├── attributes.h │ │ │ ├── audio_fifo.h │ │ │ ├── avassert.h │ │ │ ├── avconfig.h │ │ │ ├── avstring.h │ │ │ ├── avutil.h │ │ │ ├── base64.h │ │ │ ├── blowfish.h │ │ │ ├── bprint.h │ │ │ ├── bswap.h │ │ │ ├── buffer.h │ │ │ ├── camellia.h │ │ │ ├── cast5.h │ │ │ ├── channel_layout.h │ │ │ ├── common.h │ │ │ ├── cpu.h │ │ │ ├── crc.h │ │ │ ├── des.h │ │ │ ├── dict.h │ │ │ ├── display.h │ │ │ ├── downmix_info.h │ │ │ ├── encryption_info.h │ │ │ ├── error.h │ │ │ ├── eval.h │ │ │ ├── ffversion.h │ │ │ ├── fifo.h │ │ │ ├── file.h │ │ │ ├── frame.h │ │ │ ├── hash.h │ │ │ ├── hdr_dynamic_metadata.h │ │ │ ├── hmac.h │ │ │ ├── hwcontext.h │ │ │ ├── hwcontext_cuda.h │ │ │ ├── hwcontext_d3d11va.h │ │ │ ├── hwcontext_drm.h │ │ │ ├── hwcontext_dxva2.h │ │ │ ├── hwcontext_mediacodec.h │ │ │ ├── hwcontext_qsv.h │ │ │ ├── hwcontext_vaapi.h │ │ │ ├── hwcontext_vdpau.h │ │ │ ├── hwcontext_videotoolbox.h │ │ │ ├── imgutils.h │ │ │ ├── intfloat.h │ │ │ ├── intreadwrite.h │ │ │ ├── lfg.h │ │ │ ├── log.h │ │ │ ├── lzo.h │ │ │ ├── macros.h │ │ │ ├── mastering_display_metadata.h │ │ │ ├── mathematics.h │ │ │ ├── md5.h │ │ │ ├── mem.h │ │ │ ├── motion_vector.h │ │ │ ├── murmur3.h │ │ │ ├── opt.h │ │ │ ├── parseutils.h │ │ │ ├── pixdesc.h │ │ │ ├── pixelutils.h │ │ │ ├── pixfmt.h │ │ │ ├── random_seed.h │ │ │ ├── rational.h │ │ │ ├── rc4.h │ │ │ ├── replaygain.h │ │ │ ├── ripemd.h │ │ │ ├── samplefmt.h │ │ │ ├── sha.h │ │ │ ├── sha512.h │ │ │ ├── spherical.h │ │ │ ├── stereo3d.h │ │ │ ├── tea.h │ │ │ ├── threadmessage.h │ │ │ ├── time.h │ │ │ ├── timecode.h │ │ │ ├── timestamp.h │ │ │ ├── tree.h │ │ │ ├── twofish.h │ │ │ ├── tx.h │ │ │ ├── version.h │ │ │ └── xtea.h │ │ ├── libpostproc │ │ │ ├── postprocess.h │ │ │ └── version.h │ │ ├── libswresample │ │ │ ├── swresample.h │ │ │ └── version.h │ │ └── libswscale │ │ │ ├── swscale.h │ │ │ └── version.h │ └── lib │ │ ├── libavcodec-64ac49e1.so.58.91.100 │ │ ├── libavformat-4b79e479.so.58.45.100 │ │ ├── libavutil-805734e8.so.56.51.100 │ │ ├── libbz2-a273e504.so.1.0.6 │ │ ├── libcrypto-018b8c17.so.1.1 │ │ ├── libssl-6082116c.so.1.1 │ │ ├── libswresample-83ce3247.so.3.7.100 │ │ ├── libswscale-7e960168.so.5.7.100 │ │ └── libvpx-392cd848.so.6.4.0 ├── link-cuvid.sh ├── readme.md ├── src │ ├── application │ │ ├── app_demuxer.cpp │ │ └── app_hard_decode.cpp │ ├── ffhdd │ │ ├── color.cu │ │ ├── cuda_tools.cpp │ │ ├── cuda_tools.hpp │ │ ├── cuvid_decoder.cpp │ │ ├── cuvid_decoder.hpp │ │ ├── ffmpeg_demuxer.cpp │ │ ├── ffmpeg_demuxer.hpp │ │ ├── nalu.hpp │ │ ├── simple-logger.cpp │ │ └── simple-logger.hpp │ ├── interface.cpp │ └── pybind11.hpp └── workspace │ ├── exp │ ├── fall_video.mp4 │ └── number100.mp4 │ ├── test.py │ └── test_hard_decode_yolov5.py ├── example-python ├── copy_dll_to_trtpy.bat ├── pytrt │ └── __init__.py ├── setup.py ├── test_arcface.py ├── test_centernet.py ├── test_retinaface.py ├── test_scrfd.py ├── test_torch.py ├── test_yolov5.py ├── test_yolov7.py └── test_yolox.py ├── example-restful_server ├── .gitignore ├── .vscode │ ├── c_cpp_properties.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── CMakeLists.txt ├── LICENSE ├── Makefile ├── README.md ├── lean │ └── README.md ├── resful_server.sln ├── resful_server.vcxproj ├── resful_server.vcxproj.filters ├── resful_server.vcxproj.user ├── src │ ├── http │ │ ├── binary_io.cpp │ │ ├── binary_io.hpp │ │ ├── http_server.cpp │ │ ├── http_server.hpp │ │ ├── ilogger.cpp │ │ ├── ilogger.hpp │ │ ├── json.cpp │ │ ├── json.hpp │ │ ├── mongoose.c │ │ └── mongoose.h │ ├── import_lib.cpp │ ├── infer │ │ ├── simple_yolo.cu │ │ └── simple_yolo.hpp │ └── main.cpp ├── web │ ├── .gitignore │ ├── README.md │ ├── build │ │ ├── build.js │ │ ├── check-versions.js │ │ ├── logo.png │ │ ├── utils.js │ │ ├── vue-loader.conf.js │ │ ├── webpack.base.conf.js │ │ ├── webpack.dev.conf.js │ │ └── webpack.prod.conf.js │ ├── config │ │ ├── dev.env.js │ │ ├── index.js │ │ └── prod.env.js │ ├── index.html │ ├── install.sh │ ├── package-lock.json │ ├── package.json │ ├── postcss.config.js │ ├── preview.jpg │ ├── run_dev.sh │ ├── src │ │ ├── App.vue │ │ ├── assets │ │ │ ├── bbicon │ │ │ │ ├── demo.css │ │ │ │ ├── demo_index.html │ │ │ │ ├── iconfont.css │ │ │ │ ├── iconfont.eot │ │ │ │ ├── iconfont.js │ │ │ │ ├── iconfont.json │ │ │ │ ├── iconfont.svg │ │ │ │ ├── iconfont.ttf │ │ │ │ ├── iconfont.woff │ │ │ │ └── iconfont.woff2 │ │ │ └── logo.jpg │ │ ├── components │ │ │ ├── error.vue │ │ │ └── home.vue │ │ ├── http │ │ │ └── echo.js │ │ ├── main.js │ │ ├── router │ │ │ └── router.js │ │ ├── tools │ │ │ ├── tips.js │ │ │ └── tools.js │ │ └── vuex │ │ │ └── vuex.js │ └── static │ │ ├── .gitkeep │ │ └── favicon.ico └── workspace │ ├── base64-people.txt │ ├── base_decode.jpg │ ├── demo1.jpg │ ├── demo2.jpg │ ├── favicon.jpg │ ├── img.jpg │ └── web │ ├── index.html │ └── static │ ├── css │ ├── app.188f040162c3c059f9783275cc514910.css │ ├── app.188f040162c3c059f9783275cc514910.css.map │ ├── app.5151347fb0179093e29bfcc0a765248b.css │ ├── app.5151347fb0179093e29bfcc0a765248b.css.map │ ├── app.651c0fd7e35004f0463c371ca9cf1a6d.css │ ├── app.651c0fd7e35004f0463c371ca9cf1a6d.css.map │ ├── app.9c8038fe8517f2040ade83d25754811b.css │ ├── app.9c8038fe8517f2040ade83d25754811b.css.map │ ├── app.c014b898073b93d3dd99ed06828778b2.css │ ├── app.c014b898073b93d3dd99ed06828778b2.css.map │ ├── app.ce644178c8a2ee5ff2f370549400f248.css │ ├── app.ce644178c8a2ee5ff2f370549400f248.css.map │ ├── app.cf2bb188e3e7c153ce03bcdd8e82afd4.css │ ├── app.cf2bb188e3e7c153ce03bcdd8e82afd4.css.map │ ├── app.fd904077ae3708c61a024cba3eeaa6ca.css │ ├── app.fd904077ae3708c61a024cba3eeaa6ca.css.map │ ├── app.fd95e87307d5d7f35b60c65161cce5bd.css │ ├── app.fd95e87307d5d7f35b60c65161cce5bd.css.map │ ├── app.fda0ce7bb5ac4a9c1569f374b737c8d4.css │ └── app.fda0ce7bb5ac4a9c1569f374b737c8d4.css.map │ ├── favicon.ico │ ├── fonts │ ├── element-icons.535877f.woff │ ├── element-icons.732389d.ttf │ ├── iconfont.3eaa654.woff │ ├── iconfont.88a8c82.ttf │ └── iconfont.cf057b5.eot │ ├── img │ └── iconfont.c6905be.svg │ └── js │ ├── app.209c3fcfdb706db61fce.js │ ├── app.209c3fcfdb706db61fce.js.map │ ├── app.2f7bf95b78fda9d8a0d9.js │ ├── app.2f7bf95b78fda9d8a0d9.js.map │ ├── app.4b152cb02c81668ef63a.js │ ├── app.4b152cb02c81668ef63a.js.map │ ├── app.4fabec395a384f862cee.js │ ├── app.4fabec395a384f862cee.js.map │ ├── app.5367a59d18ba05ceb739.js │ ├── app.5367a59d18ba05ceb739.js.map │ ├── app.7ae7fbfdf6bdb65188bf.js │ ├── app.7ae7fbfdf6bdb65188bf.js.map │ ├── app.9680431bec6692c4d3d8.js │ ├── app.9680431bec6692c4d3d8.js.map │ ├── app.b020e61fef164e96bc54.js │ ├── app.b020e61fef164e96bc54.js.map │ ├── app.bb23fbf21592ebdbb8ab.js │ ├── app.bb23fbf21592ebdbb8ab.js.map │ ├── app.c6a9a788725bb8db467d.js │ ├── app.c6a9a788725bb8db467d.js.map │ ├── app.c7d65d40453f4a84a51a.js │ ├── app.c7d65d40453f4a84a51a.js.map │ ├── app.d1fd6f3ad3cb250b2ad8.js │ ├── app.d1fd6f3ad3cb250b2ad8.js.map │ ├── app.d2f8ab06b5c4a920ffd2.js │ ├── app.d2f8ab06b5c4a920ffd2.js.map │ ├── app.f351a7b049b42cb353ef.js │ ├── app.f351a7b049b42cb353ef.js.map │ ├── app.fada329907a8e4eab4e6.js │ ├── app.fada329907a8e4eab4e6.js.map │ ├── manifest.2ae2e69a05c33dfc65f8.js │ ├── manifest.2ae2e69a05c33dfc65f8.js.map │ ├── vendor.cb2d78080bd4fb578058.js │ └── vendor.cb2d78080bd4fb578058.js.map ├── example-simple_yolo ├── .vscode │ ├── c_cpp_properties.json │ ├── launch.json │ ├── settings.json │ └── tasks.json ├── CMakeLists.txt ├── Makefile ├── README.md ├── lean │ └── README.md ├── simple_yolo.sln ├── simple_yolo.vcxproj ├── simple_yolo.vcxproj.filters ├── simple_yolo.vcxproj.user ├── src │ ├── import_lib.cpp │ ├── main.cpp │ ├── simple_yolo.cu │ └── simple_yolo.hpp └── workspace │ ├── fix_trt7.0_resize.py │ ├── infer_8.0.1.6.jpg │ └── inference │ ├── car.jpg │ ├── gril.jpg │ ├── group.jpg │ ├── yq.jpg │ ├── zand.jpg │ └── zgjr.jpg ├── lean └── README.md ├── onnx ├── make_pb.sh ├── onnx-ml.proto └── onnx-operators-ml.proto ├── onnx_parser ├── change.log.md ├── onnx_parser_7.x │ ├── ImporterContext.hpp │ ├── LoopHelpers.cpp │ ├── LoopHelpers.hpp │ ├── ModelImporter.cpp │ ├── ModelImporter.hpp │ ├── NvOnnxParser.cpp │ ├── NvOnnxParser.h │ ├── OnnxAttrs.cpp │ ├── OnnxAttrs.hpp │ ├── RNNHelpers.cpp │ ├── RNNHelpers.hpp │ ├── ShapeTensor.cpp │ ├── ShapeTensor.hpp │ ├── ShapedWeights.cpp │ ├── ShapedWeights.hpp │ ├── Status.hpp │ ├── TensorOrWeights.hpp │ ├── builtin_op_importers.cpp │ ├── builtin_op_importers.hpp │ ├── common.hpp │ ├── onnx2trt.hpp │ ├── onnx2trt_common.hpp │ ├── onnx2trt_runtime.hpp │ ├── onnx2trt_utils.cpp │ ├── onnx2trt_utils.hpp │ ├── onnx_utils.hpp │ ├── toposort.hpp │ ├── trt_utils.hpp │ └── utils.hpp ├── onnx_parser_8.x │ ├── ImporterContext.hpp │ ├── LoopHelpers.cpp │ ├── LoopHelpers.hpp │ ├── ModelImporter.cpp │ ├── ModelImporter.hpp │ ├── NvOnnxParser.cpp │ ├── NvOnnxParser.h │ ├── OnnxAttrs.cpp │ ├── OnnxAttrs.hpp │ ├── RNNHelpers.cpp │ ├── RNNHelpers.hpp │ ├── ShapeTensor.cpp │ ├── ShapeTensor.hpp │ ├── ShapedWeights.cpp │ ├── ShapedWeights.hpp │ ├── Status.hpp │ ├── TensorOrWeights.hpp │ ├── builtin_op_importers.cpp │ ├── builtin_op_importers.hpp │ ├── onnx2trt.hpp │ ├── onnx2trt_common.hpp │ ├── onnx2trt_runtime.hpp │ ├── onnx2trt_utils.cpp │ ├── onnx2trt_utils.hpp │ ├── onnxErrorRecorder.cpp │ ├── onnxErrorRecorder.hpp │ ├── onnx_utils.hpp │ ├── readme.md │ ├── toposort.hpp │ ├── trt_utils.hpp │ └── utils.hpp ├── readme.md ├── use_tensorrt_7.x.sh └── use_tensorrt_8.x.sh ├── src ├── application │ ├── app_alphapose.cpp │ ├── app_alphapose │ │ ├── alpha_pose.cpp │ │ └── alpha_pose.hpp │ ├── app_alphapose_old │ │ ├── alpha_pose_old.cpp │ │ └── alpha_pose_old.hpp │ ├── app_arcface.cpp │ ├── app_arcface │ │ ├── arcface.cpp │ │ └── arcface.hpp │ ├── app_bert.cpp │ ├── app_centernet.cpp │ ├── app_centernet │ │ ├── centernet.cpp │ │ ├── centernet.hpp │ │ └── centernet_decode.cu │ ├── app_dbface.cpp │ ├── app_dbface │ │ ├── dbface.cpp │ │ ├── dbface.hpp │ │ └── dbface_decode.cu │ ├── app_fall_gcn │ │ ├── fall_gcn.cpp │ │ └── fall_gcn.hpp │ ├── app_fall_recognize.cpp │ ├── app_high_performance.cpp │ ├── app_high_performance │ │ ├── alpha_pose_high_perf.cpp │ │ ├── alpha_pose_high_perf.hpp │ │ ├── high_performance.cpp │ │ ├── high_performance.hpp │ │ ├── yolo_high_perf.cpp │ │ └── yolo_high_perf.hpp │ ├── app_lesson.cpp │ ├── app_plugin.cpp │ ├── app_python │ │ └── interface.cpp │ ├── app_retinaface.cpp │ ├── app_retinaface │ │ ├── retinaface.cpp │ │ ├── retinaface.hpp │ │ └── retinaface_decode.cu │ ├── app_scrfd.cpp │ ├── app_scrfd │ │ ├── scrfd.cpp │ │ ├── scrfd.hpp │ │ └── scrfd_decode.cu │ ├── app_yolo.cpp │ ├── app_yolo │ │ ├── multi_gpu.cpp │ │ ├── multi_gpu.hpp │ │ ├── yolo.cpp │ │ ├── yolo.hpp │ │ └── yolo_decode.cu │ ├── app_yolo_fast.cpp │ ├── app_yolo_fast │ │ ├── yolo_fast.cpp │ │ ├── yolo_fast.hpp │ │ ├── yolov5_decode.cu │ │ └── yolox_decode.cu │ ├── app_yolo_gpuptr.cpp │ ├── app_yolo_gpuptr │ │ ├── yolo_gpuptr.cpp │ │ ├── yolo_gpuptr.hpp │ │ └── yolo_gpuptr_decode.cu │ ├── common │ │ ├── face_detector.hpp │ │ └── object_detector.hpp │ ├── test_warpaffine.cpp │ ├── test_yolo_map.cpp │ └── tools │ │ ├── Eigen │ │ ├── CMakeLists.txt │ │ ├── Cholesky │ │ ├── CholmodSupport │ │ ├── Core │ │ ├── Dense │ │ ├── Eigen │ │ ├── Eigenvalues │ │ ├── Geometry │ │ ├── Householder │ │ ├── IterativeLinearSolvers │ │ ├── Jacobi │ │ ├── LU │ │ ├── MetisSupport │ │ ├── OrderingMethods │ │ ├── PaStiXSupport │ │ ├── PardisoSupport │ │ ├── QR │ │ ├── QtAlignedMalloc │ │ ├── SPQRSupport │ │ ├── SVD │ │ ├── Sparse │ │ ├── SparseCholesky │ │ ├── SparseCore │ │ ├── SparseLU │ │ ├── SparseQR │ │ ├── StdDeque │ │ ├── StdList │ │ ├── StdVector │ │ ├── SuperLUSupport │ │ ├── UmfPackSupport │ │ └── src │ │ │ ├── Cholesky │ │ │ ├── LDLT.h │ │ │ ├── LLT.h │ │ │ └── LLT_LAPACKE.h │ │ │ ├── CholmodSupport │ │ │ └── CholmodSupport.h │ │ │ ├── Core │ │ │ ├── Array.h │ │ │ ├── ArrayBase.h │ │ │ ├── ArrayWrapper.h │ │ │ ├── Assign.h │ │ │ ├── AssignEvaluator.h │ │ │ ├── Assign_MKL.h │ │ │ ├── BandMatrix.h │ │ │ ├── Block.h │ │ │ ├── BooleanRedux.h │ │ │ ├── CommaInitializer.h │ │ │ ├── ConditionEstimator.h │ │ │ ├── CoreEvaluators.h │ │ │ ├── CoreIterators.h │ │ │ ├── CwiseBinaryOp.h │ │ │ ├── CwiseNullaryOp.h │ │ │ ├── CwiseTernaryOp.h │ │ │ ├── CwiseUnaryOp.h │ │ │ ├── CwiseUnaryView.h │ │ │ ├── DenseBase.h │ │ │ ├── DenseCoeffsBase.h │ │ │ ├── DenseStorage.h │ │ │ ├── Diagonal.h │ │ │ ├── DiagonalMatrix.h │ │ │ ├── DiagonalProduct.h │ │ │ ├── Dot.h │ │ │ ├── EigenBase.h │ │ │ ├── ForceAlignedAccess.h │ │ │ ├── Fuzzy.h │ │ │ ├── GeneralProduct.h │ │ │ ├── GenericPacketMath.h │ │ │ ├── GlobalFunctions.h │ │ │ ├── IO.h │ │ │ ├── Inverse.h │ │ │ ├── Map.h │ │ │ ├── MapBase.h │ │ │ ├── MathFunctions.h │ │ │ ├── MathFunctionsImpl.h │ │ │ ├── Matrix.h │ │ │ ├── MatrixBase.h │ │ │ ├── NestByValue.h │ │ │ ├── NoAlias.h │ │ │ ├── NumTraits.h │ │ │ ├── PermutationMatrix.h │ │ │ ├── PlainObjectBase.h │ │ │ ├── Product.h │ │ │ ├── ProductEvaluators.h │ │ │ ├── Random.h │ │ │ ├── Redux.h │ │ │ ├── Ref.h │ │ │ ├── Replicate.h │ │ │ ├── ReturnByValue.h │ │ │ ├── Reverse.h │ │ │ ├── Select.h │ │ │ ├── SelfAdjointView.h │ │ │ ├── SelfCwiseBinaryOp.h │ │ │ ├── Solve.h │ │ │ ├── SolveTriangular.h │ │ │ ├── SolverBase.h │ │ │ ├── StableNorm.h │ │ │ ├── Stride.h │ │ │ ├── Swap.h │ │ │ ├── Transpose.h │ │ │ ├── Transpositions.h │ │ │ ├── TriangularMatrix.h │ │ │ ├── VectorBlock.h │ │ │ ├── VectorwiseOp.h │ │ │ ├── Visitor.h │ │ │ ├── arch │ │ │ │ ├── AVX │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ └── TypeCasting.h │ │ │ │ ├── AVX512 │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ └── PacketMath.h │ │ │ │ ├── AltiVec │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ └── PacketMath.h │ │ │ │ ├── CUDA │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── Half.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ ├── PacketMathHalf.h │ │ │ │ │ └── TypeCasting.h │ │ │ │ ├── Default │ │ │ │ │ └── Settings.h │ │ │ │ ├── NEON │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ └── PacketMath.h │ │ │ │ ├── SSE │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ └── TypeCasting.h │ │ │ │ └── ZVector │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ └── PacketMath.h │ │ │ ├── functors │ │ │ │ ├── AssignmentFunctors.h │ │ │ │ ├── BinaryFunctors.h │ │ │ │ ├── NullaryFunctors.h │ │ │ │ ├── StlFunctors.h │ │ │ │ ├── TernaryFunctors.h │ │ │ │ └── UnaryFunctors.h │ │ │ ├── products │ │ │ │ ├── GeneralBlockPanelKernel.h │ │ │ │ ├── GeneralMatrixMatrix.h │ │ │ │ ├── GeneralMatrixMatrixTriangular.h │ │ │ │ ├── GeneralMatrixMatrixTriangular_BLAS.h │ │ │ │ ├── GeneralMatrixMatrix_BLAS.h │ │ │ │ ├── GeneralMatrixVector.h │ │ │ │ ├── GeneralMatrixVector_BLAS.h │ │ │ │ ├── Parallelizer.h │ │ │ │ ├── SelfadjointMatrixMatrix.h │ │ │ │ ├── SelfadjointMatrixMatrix_BLAS.h │ │ │ │ ├── SelfadjointMatrixVector.h │ │ │ │ ├── SelfadjointMatrixVector_BLAS.h │ │ │ │ ├── SelfadjointProduct.h │ │ │ │ ├── SelfadjointRank2Update.h │ │ │ │ ├── TriangularMatrixMatrix.h │ │ │ │ ├── TriangularMatrixMatrix_BLAS.h │ │ │ │ ├── TriangularMatrixVector.h │ │ │ │ ├── TriangularMatrixVector_BLAS.h │ │ │ │ ├── TriangularSolverMatrix.h │ │ │ │ ├── TriangularSolverMatrix_BLAS.h │ │ │ │ └── TriangularSolverVector.h │ │ │ └── util │ │ │ │ ├── BlasUtil.h │ │ │ │ ├── Constants.h │ │ │ │ ├── DisableStupidWarnings.h │ │ │ │ ├── ForwardDeclarations.h │ │ │ │ ├── MKL_support.h │ │ │ │ ├── Macros.h │ │ │ │ ├── Memory.h │ │ │ │ ├── Meta.h │ │ │ │ ├── NonMPL2.h │ │ │ │ ├── ReenableStupidWarnings.h │ │ │ │ ├── StaticAssert.h │ │ │ │ └── XprHelper.h │ │ │ ├── Eigenvalues │ │ │ ├── ComplexEigenSolver.h │ │ │ ├── ComplexSchur.h │ │ │ ├── ComplexSchur_LAPACKE.h │ │ │ ├── EigenSolver.h │ │ │ ├── GeneralizedEigenSolver.h │ │ │ ├── GeneralizedSelfAdjointEigenSolver.h │ │ │ ├── HessenbergDecomposition.h │ │ │ ├── MatrixBaseEigenvalues.h │ │ │ ├── RealQZ.h │ │ │ ├── RealSchur.h │ │ │ ├── RealSchur_LAPACKE.h │ │ │ ├── SelfAdjointEigenSolver.h │ │ │ ├── SelfAdjointEigenSolver_LAPACKE.h │ │ │ └── Tridiagonalization.h │ │ │ ├── Geometry │ │ │ ├── AlignedBox.h │ │ │ ├── AngleAxis.h │ │ │ ├── EulerAngles.h │ │ │ ├── Homogeneous.h │ │ │ ├── Hyperplane.h │ │ │ ├── OrthoMethods.h │ │ │ ├── ParametrizedLine.h │ │ │ ├── Quaternion.h │ │ │ ├── Rotation2D.h │ │ │ ├── RotationBase.h │ │ │ ├── Scaling.h │ │ │ ├── Transform.h │ │ │ ├── Translation.h │ │ │ ├── Umeyama.h │ │ │ └── arch │ │ │ │ └── Geometry_SSE.h │ │ │ ├── Householder │ │ │ ├── BlockHouseholder.h │ │ │ ├── Householder.h │ │ │ └── HouseholderSequence.h │ │ │ ├── IterativeLinearSolvers │ │ │ ├── BasicPreconditioners.h │ │ │ ├── BiCGSTAB.h │ │ │ ├── ConjugateGradient.h │ │ │ ├── IncompleteCholesky.h │ │ │ ├── IncompleteLUT.h │ │ │ ├── IterativeSolverBase.h │ │ │ ├── LeastSquareConjugateGradient.h │ │ │ └── SolveWithGuess.h │ │ │ ├── Jacobi │ │ │ └── Jacobi.h │ │ │ ├── LU │ │ │ ├── Determinant.h │ │ │ ├── FullPivLU.h │ │ │ ├── InverseImpl.h │ │ │ ├── PartialPivLU.h │ │ │ ├── PartialPivLU_LAPACKE.h │ │ │ └── arch │ │ │ │ └── Inverse_SSE.h │ │ │ ├── MetisSupport │ │ │ └── MetisSupport.h │ │ │ ├── OrderingMethods │ │ │ ├── Amd.h │ │ │ ├── Eigen_Colamd.h │ │ │ └── Ordering.h │ │ │ ├── PaStiXSupport │ │ │ └── PaStiXSupport.h │ │ │ ├── PardisoSupport │ │ │ └── PardisoSupport.h │ │ │ ├── QR │ │ │ ├── ColPivHouseholderQR.h │ │ │ ├── ColPivHouseholderQR_LAPACKE.h │ │ │ ├── CompleteOrthogonalDecomposition.h │ │ │ ├── FullPivHouseholderQR.h │ │ │ ├── HouseholderQR.h │ │ │ └── HouseholderQR_LAPACKE.h │ │ │ ├── SPQRSupport │ │ │ └── SuiteSparseQRSupport.h │ │ │ ├── SVD │ │ │ ├── BDCSVD.h │ │ │ ├── JacobiSVD.h │ │ │ ├── JacobiSVD_LAPACKE.h │ │ │ ├── SVDBase.h │ │ │ └── UpperBidiagonalization.h │ │ │ ├── SparseCholesky │ │ │ ├── SimplicialCholesky.h │ │ │ └── SimplicialCholesky_impl.h │ │ │ ├── SparseCore │ │ │ ├── AmbiVector.h │ │ │ ├── CompressedStorage.h │ │ │ ├── ConservativeSparseSparseProduct.h │ │ │ ├── MappedSparseMatrix.h │ │ │ ├── SparseAssign.h │ │ │ ├── SparseBlock.h │ │ │ ├── SparseColEtree.h │ │ │ ├── SparseCompressedBase.h │ │ │ ├── SparseCwiseBinaryOp.h │ │ │ ├── SparseCwiseUnaryOp.h │ │ │ ├── SparseDenseProduct.h │ │ │ ├── SparseDiagonalProduct.h │ │ │ ├── SparseDot.h │ │ │ ├── SparseFuzzy.h │ │ │ ├── SparseMap.h │ │ │ ├── SparseMatrix.h │ │ │ ├── SparseMatrixBase.h │ │ │ ├── SparsePermutation.h │ │ │ ├── SparseProduct.h │ │ │ ├── SparseRedux.h │ │ │ ├── SparseRef.h │ │ │ ├── SparseSelfAdjointView.h │ │ │ ├── SparseSolverBase.h │ │ │ ├── SparseSparseProductWithPruning.h │ │ │ ├── SparseTranspose.h │ │ │ ├── SparseTriangularView.h │ │ │ ├── SparseUtil.h │ │ │ ├── SparseVector.h │ │ │ ├── SparseView.h │ │ │ └── TriangularSolver.h │ │ │ ├── SparseLU │ │ │ ├── SparseLU.h │ │ │ ├── SparseLUImpl.h │ │ │ ├── SparseLU_Memory.h │ │ │ ├── SparseLU_Structs.h │ │ │ ├── SparseLU_SupernodalMatrix.h │ │ │ ├── SparseLU_Utils.h │ │ │ ├── SparseLU_column_bmod.h │ │ │ ├── SparseLU_column_dfs.h │ │ │ ├── SparseLU_copy_to_ucol.h │ │ │ ├── SparseLU_gemm_kernel.h │ │ │ ├── SparseLU_heap_relax_snode.h │ │ │ ├── SparseLU_kernel_bmod.h │ │ │ ├── SparseLU_panel_bmod.h │ │ │ ├── SparseLU_panel_dfs.h │ │ │ ├── SparseLU_pivotL.h │ │ │ ├── SparseLU_pruneL.h │ │ │ └── SparseLU_relax_snode.h │ │ │ ├── SparseQR │ │ │ └── SparseQR.h │ │ │ ├── StlSupport │ │ │ ├── StdDeque.h │ │ │ ├── StdList.h │ │ │ ├── StdVector.h │ │ │ └── details.h │ │ │ ├── SuperLUSupport │ │ │ └── SuperLUSupport.h │ │ │ ├── UmfPackSupport │ │ │ └── UmfPackSupport.h │ │ │ ├── misc │ │ │ ├── Image.h │ │ │ ├── Kernel.h │ │ │ ├── RealSvd2x2.h │ │ │ ├── blas.h │ │ │ ├── lapack.h │ │ │ ├── lapacke.h │ │ │ └── lapacke_mangling.h │ │ │ └── plugins │ │ │ ├── ArrayCwiseBinaryOps.h │ │ │ ├── ArrayCwiseUnaryOps.h │ │ │ ├── BlockMethods.h │ │ │ ├── CommonCwiseBinaryOps.h │ │ │ ├── CommonCwiseUnaryOps.h │ │ │ ├── MatrixCwiseBinaryOps.h │ │ │ └── MatrixCwiseUnaryOps.h │ │ ├── auto_download.cpp │ │ ├── deepsort.cpp │ │ ├── deepsort.hpp │ │ ├── pybind11.hpp │ │ ├── zmq_remote_show.cpp │ │ ├── zmq_remote_show.hpp │ │ ├── zmq_u.cpp │ │ └── zmq_u.hpp ├── direct │ ├── direct_classifier.cpp │ ├── direct_mae.cpp │ ├── direct_unet.cpp │ └── direct_yolo.cpp ├── main.cpp └── tensorRT │ ├── builder │ ├── trt_builder.cpp │ └── trt_builder.hpp │ ├── common │ ├── cuda_tools.cpp │ ├── cuda_tools.hpp │ ├── ilogger.cpp │ ├── ilogger.hpp │ ├── infer_controller.hpp │ ├── json.cpp │ ├── json.hpp │ ├── monopoly_allocator.hpp │ ├── preprocess_kernel.cu │ ├── preprocess_kernel.cuh │ ├── trt_tensor.cpp │ └── trt_tensor.hpp │ ├── import_lib.cpp │ ├── infer │ ├── trt_infer.cpp │ └── trt_infer.hpp │ ├── onnx │ ├── onnx-ml.pb.cpp │ ├── onnx-ml.pb.h │ ├── onnx-operators-ml.pb.cpp │ ├── onnx-operators-ml.pb.h │ ├── onnx_pb.h │ ├── onnxifi.h │ └── readme.md │ ├── onnx_parser │ ├── ImporterContext.hpp │ ├── LoopHelpers.cpp │ ├── LoopHelpers.hpp │ ├── ModelImporter.cpp │ ├── ModelImporter.hpp │ ├── NvOnnxParser.cpp │ ├── NvOnnxParser.h │ ├── OnnxAttrs.cpp │ ├── OnnxAttrs.hpp │ ├── RNNHelpers.cpp │ ├── RNNHelpers.hpp │ ├── ShapeTensor.cpp │ ├── ShapeTensor.hpp │ ├── ShapedWeights.cpp │ ├── ShapedWeights.hpp │ ├── Status.hpp │ ├── TensorOrWeights.hpp │ ├── builtin_op_importers.cpp │ ├── builtin_op_importers.hpp │ ├── onnx2trt.hpp │ ├── onnx2trt_common.hpp │ ├── onnx2trt_runtime.hpp │ ├── onnx2trt_utils.cpp │ ├── onnx2trt_utils.hpp │ ├── onnxErrorRecorder.cpp │ ├── onnxErrorRecorder.hpp │ ├── onnx_utils.hpp │ ├── readme.md │ ├── toposort.hpp │ ├── trt_utils.hpp │ └── utils.hpp │ └── onnxplugin │ ├── onnxplugin.cpp │ ├── onnxplugin.hpp │ ├── plugin_binary_io.cpp │ ├── plugin_binary_io.hpp │ └── plugins │ ├── DCNv2.cu │ ├── HSigmoid.cu │ ├── HSwish.cu │ └── ScatterND.cu ├── tools ├── pycuda_resize.py ├── show.py ├── test_dataloader_resize.py └── test_resize.py ├── tutorial ├── 1.0framework │ ├── README.md │ ├── app_yolo.cpp │ ├── infer_controller.hpp │ ├── inference │ │ ├── car.jpg │ │ ├── f3_0.jpg │ │ ├── f3_2.jpg │ │ ├── f3_21.jpg │ │ ├── f3_210.jpg │ │ ├── f3_211.jpg │ │ ├── f3_212.jpg │ │ ├── f3_213.jpg │ │ ├── f3_214.jpg │ │ ├── f3_215.jpg │ │ ├── f3_216.jpg │ │ ├── f3_217.jpg │ │ ├── f3_218.jpg │ │ ├── f3_219.jpg │ │ ├── f3_22.jpg │ │ ├── f3_220.jpg │ │ ├── f3_221.jpg │ │ ├── f3_222.jpg │ │ ├── f3_223.jpg │ │ ├── f3_224.jpg │ │ ├── f3_225.jpg │ │ ├── f3_226.jpg │ │ ├── f3_227.jpg │ │ ├── f3_228.jpg │ │ ├── f3_229.jpg │ │ ├── f3_27.jpg │ │ ├── f3_270.jpg │ │ ├── f3_271.jpg │ │ ├── f3_272.jpg │ │ ├── f3_273.jpg │ │ ├── f3_274.jpg │ │ ├── f3_275.jpg │ │ ├── f3_276.jpg │ │ ├── f3_277.jpg │ │ ├── f3_278.jpg │ │ ├── f3_279.jpg │ │ ├── f3_29.jpg │ │ ├── f3_290.jpg │ │ ├── f3_291.jpg │ │ ├── f3_292.jpg │ │ ├── f3_293.jpg │ │ ├── f3_294.jpg │ │ ├── f3_295.jpg │ │ ├── f3_296.jpg │ │ ├── f3_297.jpg │ │ ├── f3_298.jpg │ │ ├── f3_299.jpg │ │ ├── gril.jpg │ │ ├── group.jpg │ │ ├── show.jpg │ │ ├── torch_affine.jpg │ │ ├── trt_affine.jpg │ │ ├── yq.jpg │ │ ├── zand.jpg │ │ ├── zand_copy.jpg │ │ └── zgjr.jpg │ ├── pipeline.goodnotes │ ├── pipeline.jpg │ ├── pipeline.pdf │ ├── yolo.cpp │ ├── yolo.hpp │ └── yolo_decode.cu ├── 2.0CenterNet_from_torch_trt │ ├── 0_to_1_python_to_cuda │ │ ├── cpp_cuda_centernet │ │ │ ├── .vscode │ │ │ │ ├── c_cpp_properties.json │ │ │ │ ├── launch.json │ │ │ │ ├── settings.json │ │ │ │ └── tasks.json │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── src │ │ │ │ ├── app_centernet.cpp │ │ │ │ ├── centernet.cpp │ │ │ │ ├── centernet.hpp │ │ │ │ ├── centernet_decode.cu │ │ │ │ ├── comments.jpg │ │ │ │ ├── cpp_utils.hpp │ │ │ │ ├── cuda_nms.jpg │ │ │ │ ├── cuda_utils.cuh │ │ │ │ └── main.cpp │ │ │ └── workspace │ │ │ │ ├── affined_result_cpp.jpg │ │ │ │ ├── car.jpg │ │ │ │ ├── check_preprocessed.ipynb │ │ │ │ ├── final_result_cpp.jpg │ │ │ │ ├── final_result_cuda.jpg │ │ │ │ └── test.jpg │ │ ├── model_output │ │ ├── pre_post_processing.ipynb │ │ └── truck_and_person.jpg │ ├── 5_outputs.jpg │ ├── DCNmodule_res18.png │ ├── README.md │ ├── README.zh-cn.md │ ├── all_in_one_output.jpg │ ├── comments.jpg │ ├── cuda_nms.jpg │ ├── dcn_v2.py │ ├── demo.py │ ├── export2onnx.py │ └── resnet_dcn.py ├── AboutCode.zh-cn.md ├── README.zh-cn.md ├── YoloTRT_speed.xlsx ├── ali-qr.jpg └── wechat-qr.jpg ├── windows ├── README.md ├── TensorRT.sln ├── TensorRT.vcxproj ├── TensorRT.vcxproj.filters ├── TensorRT.vcxproj.user └── dll_export.def └── workspace ├── cvt_dbface.py ├── dog.jpg ├── exp ├── face_tracker.mp4 └── fall_video.mp4 ├── face ├── library │ ├── 2ys2.jpg │ ├── 2ys3.jpg │ └── male.jpg └── recognize │ ├── 2ys1.jpg │ ├── 2ys3.jpg │ └── 2ys5.jpg ├── inference ├── car.jpg ├── gril.jpg ├── group.jpg ├── yq.jpg ├── zand.jpg └── zgjr.jpg ├── labels.imagenet.txt ├── lesson1.py ├── makesure_input.py ├── perf.result.std.log ├── pose.show.jpg ├── python_test.ipynb ├── street.jpg ├── test.jpg ├── test_dcnv2.py ├── test_hswish.py ├── unet.predict.jpg ├── vocab.txt ├── wget.exe └── yq.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/src/tensorRT 3 | tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/objs 4 | tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/pro 5 | 6 | # compressed files 7 | *.tar.gz 8 | *.zip 9 | 10 | # temp tensor and data 11 | *.tensor 12 | *.data 13 | 14 | 15 | # Prerequisites 16 | *.d 17 | 18 | # Compiled Object files 19 | *.slo 20 | *.lo 21 | *.o 22 | *.obj 23 | 24 | # Precompiled Headers 25 | *.gch 26 | *.pch 27 | 28 | # Compiled Dynamic libraries 29 | *.so 30 | *.dylib 31 | *.dll 32 | 33 | # Fortran module files 34 | *.mod 35 | *.smod 36 | 37 | # Compiled Static libraries 38 | *.lai 39 | *.la 40 | *.a 41 | *.lib 42 | 43 | # Executables 44 | *.exe 45 | *.out 46 | *.app 47 | 48 | /objs 49 | 50 | *.trtmodel 51 | *.onnx 52 | /workspace/pro 53 | /build 54 | /workspace/*.avi 55 | /workspace/.ipynb_checkpoints 56 | /workspace/*_result 57 | /workspace/face/library_draw 58 | /workspace/face/result 59 | /workspace/face/library/laq.jpg 60 | __pycache__ 61 | /tools/process_so.sh 62 | /tools/proc2.sh 63 | /python/pytrt.egg-info 64 | /python/dist 65 | /python/build 66 | /workspace/formtest.ipynb 67 | /workspace/meta.json 68 | /.vs 69 | *.pyd 70 | *.zip 71 | *.pdb 72 | *.ilk 73 | *.lib 74 | *.exp 75 | 76 | /lean/cuda10.1 77 | /lean/cudnn8.2.2.26 78 | /lean/opencv3.4.6 79 | /lean/protobuf3.11.4 80 | /lean/TensorRT-8.0.1.6 81 | 82 | __pycache__ 83 | 84 | !/workspace/wget.exe 85 | /workspace/*.mp4 86 | /workspace/single_inference 87 | /workspace/exp/tracker.final.mp4 88 | /workspace/perf.result.log 89 | /simple_yolo/workspace/pro 90 | /simple_yolo/objs 91 | /workspace/*.json 92 | /workspace/*.png 93 | /restful_server/workspace/pro 94 | /restful_server/objs 95 | /restful_server/workspace/*.trtmodel 96 | /restful_server/workspace/*.onnx -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/src/**", 7 | "/datav/lean/protobuf3.11.4/include/**", 8 | "/datav/lean/opencv-4.2.0/include/opencv4/**", 9 | "/datav/lean/cuda-10.2/include/**", 10 | "/datav/lean/TensorRT-8.0.1.6-cuda10.2-cudnn8.2/include/**", 11 | "/datav/lean/cudnn7.6.5.32-cuda10.2/include/**", 12 | "/datav/software/anaconda3/include/python3.9/**" 13 | ], 14 | "defines": ["__CUDACC__", "HAS_PYTHON"], 15 | "compilerPath": "/usr/bin/gcc", 16 | "cStandard": "gnu11", 17 | "cppStandard": "gnu++11", 18 | "intelliSenseMode": "linux-gcc-x64", 19 | "configurationProvider": "ms-vscode.makefile-tools", 20 | "browse": { 21 | "path": [ 22 | "${workspaceFolder}/src/**", 23 | "/datav/lean/protobuf3.11.4/include/**", 24 | "/datav/lean/opencv-4.2.0/include/opencv4/**", 25 | "/datav/lean/cuda-10.2/include/**", 26 | "/datav/lean/TensorRT-8.0.1.6-cuda10.2-cudnn8.2/include/**", 27 | "/datav/lean/cudnn7.6.5.32-cuda10.2/include/**", 28 | "/datav/software/anaconda3/include/python3.9/**" 29 | ], 30 | "limitSymbolsToIncludedHeaders": false, 31 | "databaseFilename": "" 32 | } 33 | } 34 | ], 35 | "version": 4 36 | } -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "(gdb) 启动", 9 | "type": "cppdbg", 10 | "request": "launch", 11 | "program": "${workspaceFolder}/workspace/pro", 12 | "args": ["yolo"], 13 | "stopAtEntry": false, 14 | "cwd": "${workspaceFolder}/workspace", 15 | "environment": [], 16 | "externalConsole": false, 17 | "MIMode": "gdb", 18 | "setupCommands": [ 19 | { 20 | "description": "为 gdb 启用整齐打印", 21 | "text": "-enable-pretty-printing", 22 | "ignoreFailures": true 23 | } 24 | ], 25 | "preLaunchTask": "build" 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "build", 8 | "type": "shell", 9 | "command": "make pro -j64" 10 | 11 | // for cmake 12 | //"command": "cd build && make pro -j25" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 TensorRTPro 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /example-hard-decode-pybind/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/src/**", 7 | "/datav/software/anaconda3/lib/python3.9/site-packages/pytrt/trt8cuda112cudnn8/include/**", 8 | "/datav/software/anaconda3/lib/python3.9/site-packages/pytrt/cpp-packages/opencv4.2/include/**", 9 | "/datav/software/anaconda3/include/python3.9", 10 | "ffmpeg-include/**", 11 | "cuvid-include/**" 12 | ], 13 | "compilerPath": "/usr/bin/gcc", 14 | "cStandard": "gnu11", 15 | "cppStandard": "gnu++11", 16 | "intelliSenseMode": "linux-gcc-x64" 17 | } 18 | ], 19 | "version": 4 20 | } -------------------------------------------------------------------------------- /example-hard-decode-pybind/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "program-debug", 6 | "type": "cppdbg", 7 | "request": "launch", 8 | "program": "${workspaceFolder}/workspace/pro", 9 | "args": [], 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}/workspace", 12 | "externalConsole": false, 13 | "MIMode": "gdb", 14 | "miDebuggerPath": "/usr/bin/gdb", 15 | "environment": [ 16 | { 17 | "name": "LD_LIBRARY_PATH", 18 | "value": "/datav/software/anaconda3/lib/python3.9/site-packages/pytrt/trt8cuda112cudnn8/lib64:/datav/software/anaconda3/lib:/datav/software/anaconda3/lib/python3.9/site-packages/pytrt/trt8cuda112cudnn8/py39:/datav/software/anaconda3/lib/python3.9/site-packages/pytrt/cpp-packages/opencv4.2/lib:/datav/software/anaconda3/lib/python3.9/site-packages/pytrt/lib:$LD_LIBRARY_PATH" 19 | } 20 | ], 21 | "setupCommands": [ 22 | { 23 | "text": "-enable-pretty-printing", 24 | "ignoreFailures": true 25 | } 26 | ], 27 | "preLaunchTask": "build" 28 | } 29 | ] 30 | } -------------------------------------------------------------------------------- /example-hard-decode-pybind/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "type": "shell", 7 | "command": "make pro -j6" 8 | } 9 | ] 10 | } -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/include/libavcodec/ac3_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AC-3 parser prototypes 3 | * Copyright (c) 2003 Fabrice Bellard 4 | * Copyright (c) 2003 Michael Niedermayer 5 | * 6 | * This file is part of FFmpeg. 7 | * 8 | * FFmpeg is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * FFmpeg is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with FFmpeg; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef AVCODEC_AC3_PARSER_H 24 | #define AVCODEC_AC3_PARSER_H 25 | 26 | #include 27 | #include 28 | 29 | /** 30 | * Extract the bitstream ID and the frame size from AC-3 data. 31 | */ 32 | int av_ac3_parse_header(const uint8_t *buf, size_t size, 33 | uint8_t *bitstream_id, uint16_t *frame_size); 34 | 35 | 36 | #endif /* AVCODEC_AC3_PARSER_H */ 37 | -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/include/libavcodec/adts_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FFmpeg. 3 | * 4 | * FFmpeg is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * FFmpeg is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with FFmpeg; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef AVCODEC_ADTS_PARSER_H 20 | #define AVCODEC_ADTS_PARSER_H 21 | 22 | #include 23 | #include 24 | 25 | #define AV_AAC_ADTS_HEADER_SIZE 7 26 | 27 | /** 28 | * Extract the number of samples and frames from AAC data. 29 | * @param[in] buf pointer to AAC data buffer 30 | * @param[out] samples Pointer to where number of samples is written 31 | * @param[out] frames Pointer to where number of frames is written 32 | * @return Returns 0 on success, error code on failure. 33 | */ 34 | int av_adts_header_parse(const uint8_t *buf, uint32_t *samples, 35 | uint8_t *frames); 36 | 37 | #endif /* AVCODEC_ADTS_PARSER_H */ 38 | -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/include/libavcodec/jni.h: -------------------------------------------------------------------------------- 1 | /* 2 | * JNI public API functions 3 | * 4 | * Copyright (c) 2015-2016 Matthieu Bouron 5 | * 6 | * This file is part of FFmpeg. 7 | * 8 | * FFmpeg is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * FFmpeg is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with FFmpeg; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef AVCODEC_JNI_H 24 | #define AVCODEC_JNI_H 25 | 26 | /* 27 | * Manually set a Java virtual machine which will be used to retrieve the JNI 28 | * environment. Once a Java VM is set it cannot be changed afterwards, meaning 29 | * you can call multiple times av_jni_set_java_vm with the same Java VM pointer 30 | * however it will error out if you try to set a different Java VM. 31 | * 32 | * @param vm Java virtual machine 33 | * @param log_ctx context used for logging, can be NULL 34 | * @return 0 on success, < 0 otherwise 35 | */ 36 | int av_jni_set_java_vm(void *vm, void *log_ctx); 37 | 38 | /* 39 | * Get the Java virtual machine which has been set with av_jni_set_java_vm. 40 | * 41 | * @param vm Java virtual machine 42 | * @return a pointer to the Java virtual machine 43 | */ 44 | void *av_jni_get_java_vm(void *log_ctx); 45 | 46 | #endif /* AVCODEC_JNI_H */ 47 | -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/include/libavutil/avconfig.h: -------------------------------------------------------------------------------- 1 | /* Generated by ffmpeg configure */ 2 | #ifndef AVUTIL_AVCONFIG_H 3 | #define AVUTIL_AVCONFIG_H 4 | #define AV_HAVE_BIGENDIAN 0 5 | #define AV_HAVE_FAST_UNALIGNED 1 6 | #endif /* AVUTIL_AVCONFIG_H */ 7 | -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/include/libavutil/ffversion.h: -------------------------------------------------------------------------------- 1 | /* Automatically generated by version.sh, do not manually edit! */ 2 | #ifndef AVUTIL_FFVERSION_H 3 | #define AVUTIL_FFVERSION_H 4 | #define FFMPEG_VERSION "4.2" 5 | #endif /* AVUTIL_FFVERSION_H */ 6 | -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/include/libavutil/hwcontext_cuda.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FFmpeg. 3 | * 4 | * FFmpeg is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * FFmpeg is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with FFmpeg; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | 20 | #ifndef AVUTIL_HWCONTEXT_CUDA_H 21 | #define AVUTIL_HWCONTEXT_CUDA_H 22 | 23 | #ifndef CUDA_VERSION 24 | #include 25 | #endif 26 | 27 | #include "pixfmt.h" 28 | 29 | /** 30 | * @file 31 | * An API-specific header for AV_HWDEVICE_TYPE_CUDA. 32 | * 33 | * This API supports dynamic frame pools. AVHWFramesContext.pool must return 34 | * AVBufferRefs whose data pointer is a CUdeviceptr. 35 | */ 36 | 37 | typedef struct AVCUDADeviceContextInternal AVCUDADeviceContextInternal; 38 | 39 | /** 40 | * This struct is allocated as AVHWDeviceContext.hwctx 41 | */ 42 | typedef struct AVCUDADeviceContext { 43 | CUcontext cuda_ctx; 44 | CUstream stream; 45 | AVCUDADeviceContextInternal *internal; 46 | } AVCUDADeviceContext; 47 | 48 | /** 49 | * AVHWFramesContext.hwctx is currently not used 50 | */ 51 | 52 | #endif /* AVUTIL_HWCONTEXT_CUDA_H */ 53 | -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/include/libavutil/hwcontext_mediacodec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FFmpeg. 3 | * 4 | * FFmpeg is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * FFmpeg is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with FFmpeg; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef AVUTIL_HWCONTEXT_MEDIACODEC_H 20 | #define AVUTIL_HWCONTEXT_MEDIACODEC_H 21 | 22 | /** 23 | * MediaCodec details. 24 | * 25 | * Allocated as AVHWDeviceContext.hwctx 26 | */ 27 | typedef struct AVMediaCodecDeviceContext { 28 | /** 29 | * android/view/Surface handle, to be filled by the user. 30 | * 31 | * This is the default surface used by decoders on this device. 32 | */ 33 | void *surface; 34 | } AVMediaCodecDeviceContext; 35 | 36 | #endif /* AVUTIL_HWCONTEXT_MEDIACODEC_H */ 37 | -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/include/libavutil/hwcontext_qsv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FFmpeg. 3 | * 4 | * FFmpeg is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * FFmpeg is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with FFmpeg; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef AVUTIL_HWCONTEXT_QSV_H 20 | #define AVUTIL_HWCONTEXT_QSV_H 21 | 22 | #include 23 | 24 | /** 25 | * @file 26 | * An API-specific header for AV_HWDEVICE_TYPE_QSV. 27 | * 28 | * This API does not support dynamic frame pools. AVHWFramesContext.pool must 29 | * contain AVBufferRefs whose data pointer points to an mfxFrameSurface1 struct. 30 | */ 31 | 32 | /** 33 | * This struct is allocated as AVHWDeviceContext.hwctx 34 | */ 35 | typedef struct AVQSVDeviceContext { 36 | mfxSession session; 37 | } AVQSVDeviceContext; 38 | 39 | /** 40 | * This struct is allocated as AVHWFramesContext.hwctx 41 | */ 42 | typedef struct AVQSVFramesContext { 43 | mfxFrameSurface1 *surfaces; 44 | int nb_surfaces; 45 | 46 | /** 47 | * A combination of MFX_MEMTYPE_* describing the frame pool. 48 | */ 49 | int frame_type; 50 | } AVQSVFramesContext; 51 | 52 | #endif /* AVUTIL_HWCONTEXT_QSV_H */ 53 | 54 | -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/include/libavutil/hwcontext_vdpau.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FFmpeg. 3 | * 4 | * FFmpeg is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * FFmpeg is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with FFmpeg; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef AVUTIL_HWCONTEXT_VDPAU_H 20 | #define AVUTIL_HWCONTEXT_VDPAU_H 21 | 22 | #include 23 | 24 | /** 25 | * @file 26 | * An API-specific header for AV_HWDEVICE_TYPE_VDPAU. 27 | * 28 | * This API supports dynamic frame pools. AVHWFramesContext.pool must return 29 | * AVBufferRefs whose data pointer is a VdpVideoSurface. 30 | */ 31 | 32 | /** 33 | * This struct is allocated as AVHWDeviceContext.hwctx 34 | */ 35 | typedef struct AVVDPAUDeviceContext { 36 | VdpDevice device; 37 | VdpGetProcAddress *get_proc_address; 38 | } AVVDPAUDeviceContext; 39 | 40 | /** 41 | * AVHWFramesContext.hwctx is currently not used 42 | */ 43 | 44 | #endif /* AVUTIL_HWCONTEXT_VDPAU_H */ 45 | -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/include/libavutil/macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FFmpeg. 3 | * 4 | * FFmpeg is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * FFmpeg is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with FFmpeg; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | /** 20 | * @file 21 | * @ingroup lavu 22 | * Utility Preprocessor macros 23 | */ 24 | 25 | #ifndef AVUTIL_MACROS_H 26 | #define AVUTIL_MACROS_H 27 | 28 | /** 29 | * @addtogroup preproc_misc Preprocessor String Macros 30 | * 31 | * String manipulation macros 32 | * 33 | * @{ 34 | */ 35 | 36 | #define AV_STRINGIFY(s) AV_TOSTRING(s) 37 | #define AV_TOSTRING(s) #s 38 | 39 | #define AV_GLUE(a, b) a ## b 40 | #define AV_JOIN(a, b) AV_GLUE(a, b) 41 | 42 | /** 43 | * @} 44 | */ 45 | 46 | #define AV_PRAGMA(s) _Pragma(#s) 47 | 48 | #define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1)) 49 | 50 | #endif /* AVUTIL_MACROS_H */ 51 | -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/include/libavutil/random_seed.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009 Baptiste Coudurier 3 | * 4 | * This file is part of FFmpeg. 5 | * 6 | * FFmpeg is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * FFmpeg is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with FFmpeg; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef AVUTIL_RANDOM_SEED_H 22 | #define AVUTIL_RANDOM_SEED_H 23 | 24 | #include 25 | /** 26 | * @addtogroup lavu_crypto 27 | * @{ 28 | */ 29 | 30 | /** 31 | * Get a seed to use in conjunction with random functions. 32 | * This function tries to provide a good seed at a best effort bases. 33 | * Its possible to call this function multiple times if more bits are needed. 34 | * It can be quite slow, which is why it should only be used as seed for a faster 35 | * PRNG. The quality of the seed depends on the platform. 36 | */ 37 | uint32_t av_get_random_seed(void); 38 | 39 | /** 40 | * @} 41 | */ 42 | 43 | #endif /* AVUTIL_RANDOM_SEED_H */ 44 | -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/include/libavutil/replaygain.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FFmpeg. 3 | * 4 | * FFmpeg is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * FFmpeg is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with FFmpeg; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef AVUTIL_REPLAYGAIN_H 20 | #define AVUTIL_REPLAYGAIN_H 21 | 22 | #include 23 | 24 | /** 25 | * ReplayGain information (see 26 | * http://wiki.hydrogenaudio.org/index.php?title=ReplayGain_1.0_specification). 27 | * The size of this struct is a part of the public ABI. 28 | */ 29 | typedef struct AVReplayGain { 30 | /** 31 | * Track replay gain in microbels (divide by 100000 to get the value in dB). 32 | * Should be set to INT32_MIN when unknown. 33 | */ 34 | int32_t track_gain; 35 | /** 36 | * Peak track amplitude, with 100000 representing full scale (but values 37 | * may overflow). 0 when unknown. 38 | */ 39 | uint32_t track_peak; 40 | /** 41 | * Same as track_gain, but for the whole album. 42 | */ 43 | int32_t album_gain; 44 | /** 45 | * Same as track_peak, but for the whole album, 46 | */ 47 | uint32_t album_peak; 48 | } AVReplayGain; 49 | 50 | #endif /* AVUTIL_REPLAYGAIN_H */ 51 | -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/include/libpostproc/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Version macros. 3 | * 4 | * This file is part of FFmpeg. 5 | * 6 | * FFmpeg is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * FFmpeg is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with FFmpeg; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef POSTPROC_VERSION_H 22 | #define POSTPROC_VERSION_H 23 | 24 | /** 25 | * @file 26 | * Libpostproc version macros 27 | */ 28 | 29 | #include "libavutil/avutil.h" 30 | 31 | #define LIBPOSTPROC_VERSION_MAJOR 55 32 | #define LIBPOSTPROC_VERSION_MINOR 5 33 | #define LIBPOSTPROC_VERSION_MICRO 100 34 | 35 | #define LIBPOSTPROC_VERSION_INT AV_VERSION_INT(LIBPOSTPROC_VERSION_MAJOR, \ 36 | LIBPOSTPROC_VERSION_MINOR, \ 37 | LIBPOSTPROC_VERSION_MICRO) 38 | #define LIBPOSTPROC_VERSION AV_VERSION(LIBPOSTPROC_VERSION_MAJOR, \ 39 | LIBPOSTPROC_VERSION_MINOR, \ 40 | LIBPOSTPROC_VERSION_MICRO) 41 | #define LIBPOSTPROC_BUILD LIBPOSTPROC_VERSION_INT 42 | 43 | #define LIBPOSTPROC_IDENT "postproc" AV_STRINGIFY(LIBPOSTPROC_VERSION) 44 | 45 | #endif /* POSTPROC_VERSION_H */ 46 | -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/lib/libavcodec-64ac49e1.so.58.91.100: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-hard-decode-pybind/ffmpeg/lib/libavcodec-64ac49e1.so.58.91.100 -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/lib/libavformat-4b79e479.so.58.45.100: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-hard-decode-pybind/ffmpeg/lib/libavformat-4b79e479.so.58.45.100 -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/lib/libavutil-805734e8.so.56.51.100: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-hard-decode-pybind/ffmpeg/lib/libavutil-805734e8.so.56.51.100 -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/lib/libbz2-a273e504.so.1.0.6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-hard-decode-pybind/ffmpeg/lib/libbz2-a273e504.so.1.0.6 -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/lib/libcrypto-018b8c17.so.1.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-hard-decode-pybind/ffmpeg/lib/libcrypto-018b8c17.so.1.1 -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/lib/libssl-6082116c.so.1.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-hard-decode-pybind/ffmpeg/lib/libssl-6082116c.so.1.1 -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/lib/libswresample-83ce3247.so.3.7.100: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-hard-decode-pybind/ffmpeg/lib/libswresample-83ce3247.so.3.7.100 -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/lib/libswscale-7e960168.so.5.7.100: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-hard-decode-pybind/ffmpeg/lib/libswscale-7e960168.so.5.7.100 -------------------------------------------------------------------------------- /example-hard-decode-pybind/ffmpeg/lib/libvpx-392cd848.so.6.4.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-hard-decode-pybind/ffmpeg/lib/libvpx-392cd848.so.6.4.0 -------------------------------------------------------------------------------- /example-hard-decode-pybind/link-cuvid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sopath=/lib/x86_64-linux-gnu 4 | 5 | if [ ! -L ${sopath}/libcuda.so ]; then 6 | files=(`find $sopath/libcuda.so*`) 7 | raw_so=${files[0]} 8 | echo Create soft link ${raw_so} 9 | sudo ln -s ${raw_so} ${sopath}/libcuda.so 10 | fi 11 | 12 | if [ ! -L ${sopath}/libnvcuvid.so ]; then 13 | echo Create soft link ${sopath}/libnvcuvid.so.1 14 | sudo ln -s ${sopath}/libnvcuvid.so.1 ${sopath}/libnvcuvid.so 15 | fi 16 | 17 | if [ ! -L ${sopath}/libnvidia-encode.so ]; then 18 | echo Create soft link ${sopath}/libnvidia-encode.so.1 19 | sudo ln -s ${sopath}/libnvidia-encode.so.1 ${sopath}/libnvidia-encode.so 20 | fi 21 | 22 | # process ffmpeg soft link 23 | files=`find ffmpeg/lib/lib*.so.*` 24 | pwd=`pwd` 25 | 26 | for file in $files 27 | do 28 | dst=`echo $file | sed 's/.so.*/.so/'` 29 | dst=`echo $dst | sed 's/-[0-9a-z]*.so/.so/'` 30 | if [ ! -L $dst ]; then 31 | echo Create ffmpeg soft link $dst 32 | ln -s $pwd/$file $pwd/$dst 33 | fi 34 | done -------------------------------------------------------------------------------- /example-hard-decode-pybind/readme.md: -------------------------------------------------------------------------------- 1 | # 硬件解码配合TensorRT 2 | 1. 配置tensorRT一样的环境 3 | 2. 增加NVDEC和ffmpeg的配置 4 | - `make run -j64` 5 | - 执行python的test.py并调用硬件解码 6 | - `make runpro -j64` 7 | - 执行c++程序进行硬件解码 8 | - `make runhdd -j64` 9 | - 执行python的test_hard_decode_yolov5.py进行tensorRT推理并对接硬件解码 10 | 3. 软解码和硬解码,分别消耗cpu和gpu资源。在多路,大分辨率下体现明显 11 | 4. 硬件解码和推理可以允许跨显卡 12 | 5. 理解并善于利用的时候,他才可能发挥最大的效果 13 | 14 | # 使用 15 | 1. 为nvcuvid创建软链接,这个库随显卡驱动发布 16 | - `bash link-cuvid.sh` 17 | 2. ffmpeg使用提供好的,或者自行编译普通cpu版本即可,不需要配置ffmpeg的cuda支持 18 | 3. 在tensorRT_Pro目录下,编译python的支持,执行`make pyinstall -j64`,并安装pytrt 19 | 4. 执行python接口的硬件解码`make run -j64` 20 | 5. 执行cpp接口的硬件解码`make runpro -j64` 21 | 6. 执行tensorRT推理对接硬件解码`make runhdd -j64` 22 | 23 | # 如果要在目录下执行 24 | - 请先将编译依赖的library path添加到PATH中,然后python test.py即可 -------------------------------------------------------------------------------- /example-hard-decode-pybind/src/ffhdd/color.cu: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | 5 | typedef unsigned char uint8_t; 6 | static __device__ uint8_t cast(float value){ 7 | return value < 0 ? 0 : (value > 255 ? 255 : value); 8 | } 9 | 10 | static __global__ void convert_nv12_to_bgr_kernel( 11 | const uint8_t* y, const uint8_t* uv, int width, int height, int linesize, uint8_t* dst_bgr, int edge 12 | ){ 13 | int position = blockDim.x * blockIdx.x + threadIdx.x; 14 | if (position >= edge) return; 15 | 16 | int ox = position % width; 17 | int oy = position / width; 18 | const uint8_t& yvalue = y[oy * linesize + ox]; 19 | int offset_uv = (oy >> 1) * linesize + (ox & 0xFFFFFFFE); 20 | const uint8_t& u = uv[offset_uv + 0]; 21 | const uint8_t& v = uv[offset_uv + 1]; 22 | dst_bgr[position * 3 + 0] = cast(1.164f * (yvalue - 16.0f) + 2.018f * (u - 128.0f)); 23 | dst_bgr[position * 3 + 1] = cast(1.164f * (yvalue - 16.0f) - 0.813f * (v - 128.0f) - 0.391f * (u - 128.0f)); 24 | dst_bgr[position * 3 + 2] = cast(1.164f * (yvalue - 16.0f) + 1.596f * (v - 128.0f)); 25 | } 26 | 27 | void convert_nv12_to_bgr_invoker( 28 | const uint8_t* y, const uint8_t* uv, int width, int height, int linesize, uint8_t* dst_bgr, 29 | cudaStream_t stream 30 | ){ 31 | int total = width * height; 32 | int block = total < 512 ? total : 512; 33 | int grid = (total + block - 1) / block; 34 | 35 | convert_nv12_to_bgr_kernel<<>>( 36 | y, uv, width, height, linesize, 37 | dst_bgr, total 38 | ); 39 | } -------------------------------------------------------------------------------- /example-hard-decode-pybind/src/ffhdd/cuvid_decoder.hpp: -------------------------------------------------------------------------------- 1 | 2 | #ifndef CUVID_DECODER_HPP 3 | #define CUVID_DECODER_HPP 4 | 5 | #include 6 | // 就不用在这里包含cuda_runtime.h 7 | 8 | struct CUstream_st; 9 | 10 | namespace FFHDDecoder{ 11 | 12 | #define IcudaVideoCodec_H264 4 13 | 14 | typedef CUstream_st* ICUStream; 15 | typedef unsigned int IcudaVideoCodec; 16 | 17 | struct CropRect { 18 | int l, t, r, b; 19 | }; 20 | 21 | struct ResizeDim { 22 | int w, h; 23 | }; 24 | 25 | class CUVIDDecoder{ 26 | public: 27 | virtual int get_frame_bytes() = 0; 28 | virtual int get_width() = 0; 29 | virtual int get_height() = 0; 30 | virtual unsigned int get_frame_index() = 0; 31 | virtual unsigned int get_num_decoded_frame() = 0; 32 | virtual uint8_t* get_frame(int64_t* pTimestamp = nullptr, unsigned int* pFrameIndex = nullptr) = 0; 33 | virtual int decode(const uint8_t *pData, int nSize, int64_t nTimestamp=0) = 0; 34 | virtual ICUStream get_stream() = 0; 35 | virtual int device() = 0; 36 | virtual bool is_gpu_frame() = 0; 37 | }; 38 | 39 | IcudaVideoCodec ffmpeg2NvCodecId(int ffmpeg_codec_id); 40 | 41 | /* max_cache 取 -1 时,无限缓存,根据实际情况缓存。实际上一般不超过5帧 */ 42 | // gpu_id = -1, current_device_id 43 | std::shared_ptr create_cuvid_decoder( 44 | bool use_device_frame, IcudaVideoCodec codec, int max_cache = -1, int gpu_id = -1, 45 | const CropRect *crop_rect = nullptr, const ResizeDim *resize_dim = nullptr, bool output_bgr = false 46 | ); 47 | }; // FFHDDecoder 48 | 49 | #endif // CUVID_DECODER_HPP -------------------------------------------------------------------------------- /example-hard-decode-pybind/src/ffhdd/ffmpeg_demuxer.hpp: -------------------------------------------------------------------------------- 1 | 2 | #ifndef FFMPEG_DEMUXER_HPP 3 | #define FFMPEG_DEMUXER_HPP 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | namespace FFHDDemuxer{ 11 | 12 | typedef int IAVCodecID; 13 | typedef int IAVPixelFormat; 14 | 15 | class DataProvider { 16 | public: 17 | virtual int get_data(uint8_t *pBuf, int nBuf) = 0; 18 | }; 19 | 20 | class FFmpegDemuxer{ 21 | public: 22 | virtual IAVCodecID get_video_codec() = 0; 23 | virtual IAVPixelFormat get_chroma_format() = 0; 24 | virtual int get_width() = 0; 25 | virtual int get_height() = 0; 26 | virtual int get_bit_depth() = 0; 27 | virtual int get_fps() = 0; 28 | virtual int get_total_frames() = 0; 29 | virtual void get_extra_data(uint8_t **ppData, int *bytes) = 0; 30 | virtual bool isreboot() = 0; 31 | virtual void reset_reboot_flag() = 0; 32 | virtual bool demux(uint8_t **ppVideo, int *pnVideoBytes, int64_t *pts = nullptr, bool *iskey_frame = nullptr) = 0; 33 | virtual bool reopen() = 0; 34 | }; 35 | 36 | std::shared_ptr create_ffmpeg_demuxer(const std::string& uri, bool auto_reboot = false); 37 | std::shared_ptr create_ffmpeg_demuxer(std::shared_ptr provider); 38 | }; // namespace FFHDDemuxer 39 | 40 | #endif // FFMPEG_DEMUXER_HPP -------------------------------------------------------------------------------- /example-hard-decode-pybind/src/ffhdd/simple-logger.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SIMPLE_LOGGER_HPP 2 | #define SIMPLE_LOGGER_HPP 3 | 4 | #include 5 | 6 | #define INFOD(...) SimpleLogger::__log_func(__FILE__, __LINE__, SimpleLogger::LogLevel::Debug, __VA_ARGS__) 7 | #define INFOV(...) SimpleLogger::__log_func(__FILE__, __LINE__, SimpleLogger::LogLevel::Verbose, __VA_ARGS__) 8 | #define INFO(...) SimpleLogger::__log_func(__FILE__, __LINE__, SimpleLogger::LogLevel::Info, __VA_ARGS__) 9 | #define INFOW(...) SimpleLogger::__log_func(__FILE__, __LINE__, SimpleLogger::LogLevel::Warning, __VA_ARGS__) 10 | //#define INFOE(...) SimpleLogger::__log_func(__FILE__, __LINE__, SimpleLogger::LogLevel::Error, __VA_ARGS__) 11 | #define INFOE(...) SimpleLogger::__log_func(__FILE__, __LINE__, SimpleLogger::LogLevel::Info, __VA_ARGS__) //修改为info,使用infoe python层会crash MIke 2020--5-11 12 | #define INFOF(...) SimpleLogger::__log_func(__FILE__, __LINE__, SimpleLogger::LogLevel::Fatal, __VA_ARGS__) 13 | 14 | 15 | namespace SimpleLogger{ 16 | 17 | enum class LogLevel : int{ 18 | Debug = 5, 19 | Verbose = 4, 20 | Info = 3, 21 | Warning = 2, 22 | Error = 1, 23 | Fatal = 0 24 | }; 25 | 26 | void set_log_level(LogLevel level); 27 | LogLevel get_log_level(); 28 | void __log_func(const char* file, int line, LogLevel level, const char* fmt, ...); 29 | 30 | }; // SimpleLogger 31 | 32 | #endif // SIMPLE_LOGGER_HPP 33 | -------------------------------------------------------------------------------- /example-hard-decode-pybind/workspace/exp/fall_video.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-hard-decode-pybind/workspace/exp/fall_video.mp4 -------------------------------------------------------------------------------- /example-hard-decode-pybind/workspace/exp/number100.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-hard-decode-pybind/workspace/exp/number100.mp4 -------------------------------------------------------------------------------- /example-python/copy_dll_to_trtpy.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | copy ..\lean\cuda10.1\bin\cublas64_100.dll .\pytrt\ 3 | copy ..\lean\cuda10.1\bin\cublasLt64_10.dll .\pytrt\ 4 | copy ..\lean\cuda10.1\bin\cudart64_101.dll .\pytrt\ 5 | copy ..\lean\cuda10.1\bin\cublas64_10.dll .\pytrt\ 6 | 7 | copy ..\lean\opencv3.4.6\lib\opencv_world346.dll .\pytrt\ 8 | copy ..\lean\TensorRT-8.0.1.6\lib\nvinfer.dll .\pytrt\ 9 | copy ..\lean\TensorRT-8.0.1.6\lib\nvinfer_plugin.dll .\pytrt\ 10 | copy ..\lean\cudnn8.2.2.26\*.dll .\pytrt\ 11 | 12 | -------------------------------------------------------------------------------- /example-python/setup.py: -------------------------------------------------------------------------------- 1 | 2 | from setuptools import find_packages 3 | from setuptools import setup 4 | import platform 5 | import os 6 | 7 | os_name = platform.system() 8 | if os_name == "Linux": 9 | cpp_library = ["libpytrtc.so", "libplugin_list.so"] 10 | elif os_name == "Windows": 11 | os.system("copy_dll_to_pytrt.bat") 12 | cpp_library = [ 13 | "libpytrtc.pyd", 14 | "cublas64_10.dll", 15 | "cublas64_100.dll", 16 | "cublasLt64_10.dll", 17 | "cudart64_101.dll", 18 | "cudnn64_8.dll", 19 | "cudnn_adv_infer64_8.dll", 20 | "cudnn_adv_train64_8.dll", 21 | "cudnn_cnn_infer64_8.dll", 22 | "cudnn_cnn_train64_8.dll", 23 | "cudnn_ops_infer64_8.dll", 24 | "cudnn_ops_train64_8.dll", 25 | "nvinfer.dll", 26 | "nvinfer_plugin.dll", 27 | "opencv_world346.dll" 28 | ] 29 | 30 | else: 31 | raise RuntimeError(f"Unsupport platform {os_name}") 32 | 33 | setup( 34 | name="pytrt", 35 | version="1.0", 36 | author="Wish", 37 | url="https://github.com/shouxieai/tensorRT_cpp", 38 | description="tensorRT CPP/Python", 39 | packages=find_packages(), 40 | package_data={ 41 | "": cpp_library 42 | }, 43 | zip_safe=False 44 | ) -------------------------------------------------------------------------------- /example-python/test_centernet.py: -------------------------------------------------------------------------------- 1 | import os 2 | import cv2 3 | import numpy as np 4 | import pytrt as tp 5 | 6 | # change current workspace 7 | os.chdir("../workspace/") 8 | 9 | # 如果执行出错,请删掉 ~/.pytrt 的缓存模型 10 | # rm -rf ~/.pytrt,重新下载 11 | engine_file = "centernet_r18_dcn.fp32.trtmodel" 12 | if not os.path.exists(engine_file): 13 | tp.compile_onnx_to_file(5, tp.onnx_hub("centernet_r18_dcn"), engine_file) 14 | 15 | model = tp.CenterNet(engine_file) 16 | image = cv2.imread("inference/car.jpg") 17 | bboxes = model.commit(image).get() 18 | print(f"{len(bboxes)} objects") 19 | 20 | for box in bboxes: 21 | print(box) 22 | left, top, right, bottom = map(int, [box.left, box.top, box.right, box.bottom]) 23 | cv2.rectangle(image, (left, top), (right, bottom), tp.random_color(box.class_label), 5) 24 | 25 | os.makedirs("single_inference", exist_ok=True) 26 | saveto = "single_inference/centernet.car.jpg" 27 | print(f"Save to {saveto}") 28 | 29 | cv2.imwrite(saveto, image) 30 | 31 | -------------------------------------------------------------------------------- /example-python/test_torch.py: -------------------------------------------------------------------------------- 1 | 2 | import torch 3 | import torchvision.models as models 4 | import pytrt as tp 5 | import numpy as np 6 | import os 7 | 8 | os.chdir("../workspace/") 9 | device = "cuda" if torch.cuda.is_available() else "cpu" 10 | 11 | # 基于torch的tensor输入 12 | input = torch.full((5, 3, 224, 224), 0.3).to(device) 13 | model = models.resnet18(True).eval().to(device) 14 | trt_model = tp.from_torch(model, input, 15 | engine_save_file = "torch.engine.trtmodel", 16 | onnx_save_file = "torch.onnx" 17 | ) 18 | 19 | torch_out = model(input) 20 | trt_out = trt_model(input) 21 | 22 | trt_model.save("torch.trtmodel") 23 | 24 | abs_diff = (torch_out - trt_out).abs().max() 25 | print(f"Torch and TRTModel abs diff is {abs_diff}") 26 | 27 | print(f"trt_model.stream is {trt_model.stream}") 28 | print(trt_model.input().shape) 29 | trt_model.input().resize_single_dim(0, 1) 30 | print(trt_model.input().shape) 31 | trt_model.input().resize_single_dim(0, 5) 32 | 33 | # 获取模型的input,并对输入进行赋值为0.5 34 | trt_model.input().numpy[:] = 0.5 35 | 36 | # 执行推理 37 | trt_model.forward() 38 | 39 | # 获取输出 40 | trt_out = trt_model.output().numpy 41 | 42 | #对torch进行推理 43 | input[:] = 0.5 44 | torch_out = model(input).cpu().data.numpy() 45 | 46 | # 对比差距绝对值 47 | abs_diff = np.abs(torch_out - trt_out).max() 48 | print(f"Torch and TRTModel abs diff is {abs_diff}") -------------------------------------------------------------------------------- /example-python/test_yolox.py: -------------------------------------------------------------------------------- 1 | import os 2 | import cv2 3 | import numpy as np 4 | import pytrt as tp 5 | 6 | # change current workspace 7 | os.chdir("../workspace/") 8 | 9 | # 如果执行出错,请删掉 ~/.pytrt 的缓存模型 10 | # rm -rf ~/.pytrt,重新下载 11 | engine_file = "yolox_m.fp32.trtmodel" 12 | if not os.path.exists(engine_file): 13 | tp.compile_onnx_to_file(5, tp.onnx_hub("yolox_m"), engine_file) 14 | 15 | yolo = tp.Yolo(engine_file, type=tp.YoloType.X) 16 | image = cv2.imread("inference/car.jpg") 17 | bboxes = yolo.commit(image).get() 18 | print(f"{len(bboxes)} objects") 19 | 20 | for box in bboxes: 21 | print(f"{box}") 22 | left, top, right, bottom = map(int, [box.left, box.top, box.right, box.bottom]) 23 | cv2.rectangle(image, (left, top), (right, bottom), tp.random_color(box.class_label), 5) 24 | 25 | os.makedirs("single_inference", exist_ok=True) 26 | saveto = "single_inference/yolox.car.jpg" 27 | print(f"Save to {saveto}") 28 | 29 | cv2.imwrite(saveto, image) 30 | -------------------------------------------------------------------------------- /example-restful_server/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | /objs 35 | /workspace/pro 36 | /workspace/logs -------------------------------------------------------------------------------- /example-restful_server/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/src/**", 7 | "/data/sxai/lean/protobuf3.11.4/include/**", 8 | "/data/sxai/lean/opencv4.2.0/include/opencv4/**", 9 | "/data/sxai/lean/cuda-10.2/include/**", 10 | "/data/sxai/lean/TensorRT-8.0.1.6-cuda10.2-cudnn8.2/include/**", 11 | "/data/sxai/lean/cudnn7.6.5.32-cuda10.2/include/**", 12 | "/data/datav/newbb/lean/anaconda3/envs/torch1.8/include/python3.9/**" 13 | ], 14 | "defines": ["__CUDACC__", "HAS_PYTHON"], 15 | "compilerPath": "/usr/bin/gcc", 16 | "cStandard": "gnu11", 17 | "cppStandard": "gnu++11", 18 | "intelliSenseMode": "linux-gcc-x64", 19 | "configurationProvider": "ms-vscode.makefile-tools", 20 | "browse": { 21 | "path": [ 22 | "${workspaceFolder}/src/**", 23 | "/data/sxai/lean/protobuf3.11.4/include/**", 24 | "/data/sxai/lean/opencv4.2.0/include/opencv4/**", 25 | "/data/sxai/lean/cuda-10.2/include/**", 26 | "/data/sxai/lean/TensorRT-8.0.1.6-cuda10.2-cudnn8.2/include/**", 27 | "/data/sxai/lean/cudnn7.6.5.32-cuda10.2/include/**", 28 | "/data/datav/newbb/lean/anaconda3/envs/torch1.8/include/python3.9/**" 29 | ], 30 | "limitSymbolsToIncludedHeaders": false, 31 | "databaseFilename": "" 32 | } 33 | } 34 | ], 35 | "version": 4 36 | } -------------------------------------------------------------------------------- /example-restful_server/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "(gdb) 启动", 9 | "type": "cppdbg", 10 | "request": "launch", 11 | "program": "${workspaceFolder}/workspace/pro", 12 | "args": ["yolo"], 13 | "stopAtEntry": false, 14 | "cwd": "${workspaceFolder}/workspace", 15 | "environment": [], 16 | "externalConsole": false, 17 | "MIMode": "gdb", 18 | "setupCommands": [ 19 | { 20 | "description": "为 gdb 启用整齐打印", 21 | "text": "-enable-pretty-printing", 22 | "ignoreFailures": true 23 | } 24 | ], 25 | "preLaunchTask": "build" 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /example-restful_server/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "build", 8 | "type": "shell", 9 | "command": "make pro -j64" 10 | 11 | // for cmake 12 | //"command": "cd build && make pro -j25" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /example-restful_server/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 手写AI 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /example-restful_server/README.md: -------------------------------------------------------------------------------- 1 | # 基于Yolo推理的Resful API http server 2 | - C++的http服务器,简单好用 3 | ![](web/preview.jpg) 4 | 5 | ## 执行方式 6 | ```bash 7 | make run -j6 8 | ``` 9 | 10 | ## HTTP服务的案例代码 11 | ```C++ 12 | #include "http_server.hpp" 13 | 14 | using namespace std; 15 | 16 | // 定义控制器,处理路由对应的请求,MVC模式里边的C部分, 17 | class LogicalController : public Controller{ 18 | SetupController(LogicalController); 19 | 20 | public: 21 | // 轻易请求的映射,这里的名称就是路由的地址 22 | DefRequestMapping(getReturn); 23 | }; 24 | 25 | // 定义路由的处理函数,类java spring。这里使用返回值作为response。实际上支持多种,请看具体代码 26 | Json::Value LogicalController::getReturn(const Json::Value& param){ 27 | 28 | Json::Value data; 29 | data["alpha"] = 3.15; 30 | data["name"] = "张三"; 31 | return success(data); 32 | } 33 | 34 | int main(int argc, char** argv) { 35 | 36 | // 创建http服务器,具有32个线程 37 | auto server = createHttpServer("0.0.0.0:8090", 32); 38 | if(server == nullptr) return -1; 39 | 40 | // 添加控制器对于路由v1 41 | server->add_controller("/v1", make_shared()); 42 | 43 | // 添加静态文件访问,对于路由/static,绑定到路径./上 44 | server->add_controller("/static", create_file_access_controller("./")); 45 | return while_loop(); 46 | } 47 | ``` 48 | 49 | ## 效果 50 | ![](workspace/demo1.jpg) 51 | ![](workspace/demo2.jpg) 52 | 53 | ## 关于我们 54 | - 我们的博客是:http://www.zifuture.com:8090/ 55 | - 我们的B站地址是:https://space.bilibili.com/1413433465 -------------------------------------------------------------------------------- /example-restful_server/lean/README.md: -------------------------------------------------------------------------------- 1 | # About dependencies 2 | - CUDA10.1 3 | - CUDNN8.2.2.26 4 | - OpenCV3.4.6 or 4.x 5 | - the above three are modifiable as long as being compatible to TensorRT 6 | - Protobuf3.11.4 (unmodifiable, otherwise problematic) 7 | - tensorrt-8.0.1.6 8 | # For Windows 9 | - Visual Studio 2017 (>=2017) 10 | - [download the lean.rar](http://zifuture.com:1556/fs/sxai/lean.rar). 11 | 12 | *** 13 | 14 | # 关于依赖 15 | - CUDA10.1 (可修改,适配TensorRT即可) 16 | - CUDNN8.2.2.26 (可修改,适配 TensorRT即可) 17 | - OpenCV3.4.6 (可修改) 18 | - Protobuf3.11.4 (不可修改,否则问题多多) 19 | - TensorRT-8.0.1.6 20 | 21 | # 对于Windows而言 22 | - Visual Studio 2017 (请大于等于2017) 23 | - [点击下载打包好的lean.rar](http://zifuture.com:1556/fs/sxai/lean.rar) 24 | 25 | -------------------------------------------------------------------------------- /example-restful_server/resful_server.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.902 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "resful_server", "resful_server.vcxproj", "{01968AE1-519E-48CB-827B-E0D317B7707D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {01968AE1-519E-48CB-827B-E0D317B7707D}.Debug|x64.ActiveCfg = Debug|x64 17 | {01968AE1-519E-48CB-827B-E0D317B7707D}.Debug|x64.Build.0 = Debug|x64 18 | {01968AE1-519E-48CB-827B-E0D317B7707D}.Debug|x86.ActiveCfg = Debug|Win32 19 | {01968AE1-519E-48CB-827B-E0D317B7707D}.Debug|x86.Build.0 = Debug|Win32 20 | {01968AE1-519E-48CB-827B-E0D317B7707D}.Release|x64.ActiveCfg = Release|x64 21 | {01968AE1-519E-48CB-827B-E0D317B7707D}.Release|x64.Build.0 = Release|x64 22 | {01968AE1-519E-48CB-827B-E0D317B7707D}.Release|x86.ActiveCfg = Release|Win32 23 | {01968AE1-519E-48CB-827B-E0D317B7707D}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {87D7384D-E9D2-4F69-8099-77F1328568F7} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /example-restful_server/resful_server.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | workspace 5 | PATH=$(projectDir)lean/cuda10.1/bin;$(projectDir)lean/opencv3.4.6/lib;$(projectDir)lean/cudnn8.2.2.26;$(projectDir)lean/TensorRT-8.0.1.6/lib 6 | WindowsLocalDebugger 7 | 8 | 9 | workspace 10 | PATH=$(projectDir)lean/cuda10.1/bin;$(projectDir)lean/opencv3.4.6/lib;$(projectDir)lean/cudnn8.2.2.26;$(projectDir)lean/TensorRT-8.0.1.6/lib 11 | WindowsLocalDebugger 12 | 13 | -------------------------------------------------------------------------------- /example-restful_server/src/import_lib.cpp: -------------------------------------------------------------------------------- 1 |  2 | #if defined(_WIN32) 3 | # define U_OS_WINDOWS 4 | #else 5 | # define U_OS_LINUX 6 | #endif 7 | 8 | #ifdef U_OS_WINDOWS 9 | #if defined(_DEBUG) 10 | # pragma comment(lib, "opencv_world346d.lib") 11 | #else 12 | # pragma comment(lib, "opencv_world346.lib") 13 | #endif 14 | 15 | //导入cuda 16 | #pragma comment(lib, "cuda.lib") 17 | #pragma comment(lib, "cudart.lib") 18 | #pragma comment(lib, "cublas.lib") 19 | #pragma comment(lib, "cudnn.lib") 20 | 21 | //导入tensorRT 22 | #pragma comment(lib, "nvinfer.lib") 23 | #pragma comment(lib, "nvinfer_plugin.lib") 24 | #pragma comment(lib, "nvonnxparser.lib") 25 | 26 | #endif // U_OS_WINDOWS -------------------------------------------------------------------------------- /example-restful_server/web/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /node-v12.4.0-linux-x64 -------------------------------------------------------------------------------- /example-restful_server/web/README.md: -------------------------------------------------------------------------------- 1 | # 关于Web项目自定义开发 2 | 1. 下载node-v12.4.0-linux-x64 3 | - windows下请模拟配置 4 | 2. `cd web` 5 | 3. `export PATH=$PATH:node-v12.4.0-linux-x64/bin` 6 | 4. `npm config set registry https://registry.npm.taobao.org` 7 | 5. `npm install` 8 | 6. `npm run build` 9 | 10 | ## 若要进入开发模式 11 | 1. `cd web` 12 | 2. `bash run_dev.sh` 13 | 14 | ## 效果图 15 | ![](preview.jpg) -------------------------------------------------------------------------------- /example-restful_server/web/build/build.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | require('./check-versions')() 3 | 4 | process.env.NODE_ENV = 'production' 5 | 6 | const cp = require('child_process'); 7 | const ora = require('ora') 8 | const rm = require('rimraf') 9 | const path = require('path') 10 | const chalk = require('chalk') 11 | const webpack = require('webpack') 12 | const config = require('../config') 13 | const webpackConfig = require('./webpack.prod.conf') 14 | 15 | const spinner = ora('building for production...') 16 | spinner.start() 17 | 18 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { 19 | if (err) throw err 20 | webpack(webpackConfig, (err, stats) => { 21 | spinner.stop() 22 | if (err) throw err 23 | process.stdout.write(stats.toString({ 24 | colors: true, 25 | modules: false, 26 | children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build. 27 | chunks: false, 28 | chunkModules: false 29 | }) + '\n\n') 30 | 31 | if (stats.hasErrors()) { 32 | console.log(chalk.red(' Build failed with errors.\n')) 33 | process.exit(1) 34 | } 35 | 36 | console.log(chalk.cyan(' Build complete.\n')) 37 | console.log(chalk.yellow( 38 | ' Tip: built files are meant to be served over an HTTP server.\n' + 39 | ' Opening index.html over file:// won\'t work.\n' 40 | )) 41 | 42 | cp.exec("bash install.sh") 43 | }) 44 | }) 45 | -------------------------------------------------------------------------------- /example-restful_server/web/build/check-versions.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const chalk = require('chalk') 3 | const semver = require('semver') 4 | const packageConfig = require('../package.json') 5 | const shell = require('shelljs') 6 | 7 | function exec (cmd) { 8 | return require('child_process').execSync(cmd).toString().trim() 9 | } 10 | 11 | const versionRequirements = [ 12 | { 13 | name: 'node', 14 | currentVersion: semver.clean(process.version), 15 | versionRequirement: packageConfig.engines.node 16 | } 17 | ] 18 | 19 | if (shell.which('npm')) { 20 | versionRequirements.push({ 21 | name: 'npm', 22 | currentVersion: exec('npm --version'), 23 | versionRequirement: packageConfig.engines.npm 24 | }) 25 | } 26 | 27 | module.exports = function () { 28 | const warnings = [] 29 | 30 | for (let i = 0; i < versionRequirements.length; i++) { 31 | const mod = versionRequirements[i] 32 | 33 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { 34 | warnings.push(mod.name + ': ' + 35 | chalk.red(mod.currentVersion) + ' should be ' + 36 | chalk.green(mod.versionRequirement) 37 | ) 38 | } 39 | } 40 | 41 | if (warnings.length) { 42 | console.log('') 43 | console.log(chalk.yellow('To use this template, you must update following to modules:')) 44 | console.log() 45 | 46 | for (let i = 0; i < warnings.length; i++) { 47 | const warning = warnings[i] 48 | console.log(' ' + warning) 49 | } 50 | 51 | console.log() 52 | process.exit(1) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /example-restful_server/web/build/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/web/build/logo.png -------------------------------------------------------------------------------- /example-restful_server/web/build/vue-loader.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const utils = require('./utils') 3 | const config = require('../config') 4 | const isProduction = process.env.NODE_ENV === 'production' 5 | const sourceMapEnabled = isProduction 6 | ? config.build.productionSourceMap 7 | : config.dev.cssSourceMap 8 | 9 | module.exports = { 10 | loaders: utils.cssLoaders({ 11 | sourceMap: sourceMapEnabled, 12 | extract: isProduction 13 | }), 14 | cssSourceMap: sourceMapEnabled, 15 | cacheBusting: config.dev.cacheBusting, 16 | transformToRequire: { 17 | video: ['src', 'poster'], 18 | source: 'src', 19 | img: 'src', 20 | image: 'xlink:href' 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /example-restful_server/web/config/dev.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const prodEnv = require('./prod.env') 4 | 5 | module.exports = merge(prodEnv, { 6 | NODE_ENV: '"development"' 7 | }) 8 | -------------------------------------------------------------------------------- /example-restful_server/web/config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /example-restful_server/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Resful API 8 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /example-restful_server/web/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p ../workspace/web 4 | cp -r dist/* ../workspace/web -------------------------------------------------------------------------------- /example-restful_server/web/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | 'autoprefixer': {browsers: 'last 5 version'} 4 | } 5 | } -------------------------------------------------------------------------------- /example-restful_server/web/preview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/web/preview.jpg -------------------------------------------------------------------------------- /example-restful_server/web/run_dev.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export PATH=$PATH:node-v12.4.0-linux-x64/bin 4 | 5 | npm run dev -------------------------------------------------------------------------------- /example-restful_server/web/src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | 15 | -------------------------------------------------------------------------------- /example-restful_server/web/src/assets/bbicon/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/web/src/assets/bbicon/iconfont.eot -------------------------------------------------------------------------------- /example-restful_server/web/src/assets/bbicon/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/web/src/assets/bbicon/iconfont.ttf -------------------------------------------------------------------------------- /example-restful_server/web/src/assets/bbicon/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/web/src/assets/bbicon/iconfont.woff -------------------------------------------------------------------------------- /example-restful_server/web/src/assets/bbicon/iconfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/web/src/assets/bbicon/iconfont.woff2 -------------------------------------------------------------------------------- /example-restful_server/web/src/assets/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/web/src/assets/logo.jpg -------------------------------------------------------------------------------- /example-restful_server/web/src/components/error.vue: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /example-restful_server/web/src/main.js: -------------------------------------------------------------------------------- 1 | // The Vue build version to load with the `import` command 2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias. 3 | import Vue from 'vue' 4 | import App from '@/App' 5 | import router from '@/router/router' 6 | import store from '@/vuex/vuex' 7 | import Echo from '@/http/echo.js' 8 | import ElementUI from 'element-ui' 9 | import 'element-ui/lib/theme-chalk/index.css' 10 | import "@/assets/bbicon/iconfont.css" 11 | import VueCookies from 'vue-cookies' 12 | import Tips from "@/tools/tips.js" 13 | import Tools from "@/tools/tools.js" 14 | 15 | Vue.use(ElementUI) 16 | Vue.use(VueCookies) 17 | 18 | //将需要的东西注入到全局 19 | window["Echo"] = Echo 20 | window["Tips"] = Tips 21 | window["Tools"] = Tools 22 | 23 | Vue.config.productionTip = false 24 | 25 | //请求前的时候打开loading 26 | let loadingLayer = null 27 | Echo.setPreQueryCallback((query)=>{ 28 | 29 | if(query._loadingSilence) 30 | return; 31 | 32 | if(loadingLayer != null) 33 | return 34 | 35 | loadingLayer = ElementUI.Loading.service({ 36 | fullscreen: true, 37 | lock: true, 38 | text: "加载中...", 39 | background: "rgba(0, 0, 0, 0.5)" 40 | //spinner: 'el-icon-loading', 41 | //target: ".data-content" 42 | }) 43 | }) 44 | 45 | //请求结束后,关闭loading 46 | Echo.setEndQueryCallback((query, data)=>{ 47 | 48 | if(loadingLayer != null){ 49 | loadingLayer.close() 50 | loadingLayer = null 51 | } 52 | 53 | //如果不正确的结果返回,就提示错误 54 | if(data && data.status != "success"){ 55 | if(!query._tipsSilence){ 56 | Tips.error(data.message) 57 | }else{ 58 | console.log("请求结束静默,不提示:" + data.msg) 59 | } 60 | } 61 | }) 62 | 63 | new Vue({ 64 | el: '#app', 65 | router, 66 | store, 67 | components: { App }, 68 | template: '' 69 | }) -------------------------------------------------------------------------------- /example-restful_server/web/src/router/router.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import Echo from '@/http/echo' 4 | import Error from "@/components/error" 5 | import Home from "@/components/home" 6 | import Tips from '@/tools/tips' 7 | import { local } from 'd3' 8 | 9 | Vue.use(Router) 10 | const originalPush = Router.prototype.push 11 | 12 | Router.prototype.push = function push(location) { 13 | return originalPush.call(this, location).catch(err => err) 14 | } 15 | 16 | const routes = [ 17 | { 18 | path: "/", 19 | component: Home 20 | }, 21 | { 22 | path: "*", 23 | component: Error 24 | } 25 | ] 26 | 27 | const router = new Router({ 28 | mode: 'history', 29 | routes: routes 30 | }) 31 | 32 | router.beforeEach(function(to, from, next){ 33 | return next() 34 | }) 35 | export default router -------------------------------------------------------------------------------- /example-restful_server/web/src/tools/tips.js: -------------------------------------------------------------------------------- 1 | import ElementUI from 'element-ui' 2 | import Vue from 'vue' 3 | 4 | function pack_opt(opt_or_message, title){ 5 | 6 | let opt = {} 7 | if(typeof(opt_or_message) == "string"){ 8 | opt["message"] = opt_or_message 9 | opt["title"] = title 10 | }else{ 11 | opt = opt_or_message 12 | } 13 | 14 | if(!("duration" in opt)) 15 | opt["duration"] = 2000 16 | return opt 17 | } 18 | 19 | function tips_success(opt_or_message, title = "成功"){ 20 | let opt = pack_opt(opt_or_message, title) 21 | ElementUI.Notification.success(opt) 22 | } 23 | 24 | function tips_error(opt_or_message, title = "错误"){ 25 | let opt = pack_opt(opt_or_message, title) 26 | ElementUI.Notification.error(opt) 27 | } 28 | 29 | function tips_info(opt_or_message, title = "提示"){ 30 | let opt = pack_opt(opt_or_message, title) 31 | ElementUI.Notification.info(opt) 32 | } 33 | 34 | function tips_warning(opt_or_message, title = "警告"){ 35 | let opt = pack_opt(opt_or_message, title) 36 | ElementUI.Notification.warning(opt) 37 | } 38 | 39 | function tips_tip(opt){ 40 | ElementUI.Notification(opt) 41 | } 42 | 43 | const Tips = { 44 | success: tips_success, 45 | error: tips_error, 46 | info: tips_info, 47 | warning: tips_warning, 48 | tip: tips_tip 49 | } 50 | 51 | Vue.prototype.$tips = Tips 52 | export default Tips -------------------------------------------------------------------------------- /example-restful_server/web/src/tools/tools.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | function clone(obj) { 8 | 9 | let o; 10 | if (typeof obj == "object") { 11 | if (obj === null) { 12 | o = null; 13 | } else { 14 | if (obj instanceof Array) { 15 | o = []; 16 | for (let i = 0, len = obj.length; i < len; i++) { 17 | o.push(clone(obj[i])); 18 | } 19 | } else { 20 | o = {}; 21 | for (let j in obj) { 22 | o[j] = clone(obj[j]); 23 | } 24 | } 25 | } 26 | } else { 27 | o = obj; 28 | } 29 | return o; 30 | } 31 | 32 | const Tools = { 33 | clone 34 | } 35 | 36 | 37 | export default Tools -------------------------------------------------------------------------------- /example-restful_server/web/src/vuex/vuex.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | 4 | Vue.use(Vuex) 5 | 6 | export default new Vuex.Store({ 7 | state: { 8 | userInfo: "" 9 | }, 10 | mutations: { 11 | updateUser(state, info){ 12 | state.userInfo = info 13 | } 14 | } 15 | }) -------------------------------------------------------------------------------- /example-restful_server/web/static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/web/static/.gitkeep -------------------------------------------------------------------------------- /example-restful_server/web/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/web/static/favicon.ico -------------------------------------------------------------------------------- /example-restful_server/workspace/base_decode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/workspace/base_decode.jpg -------------------------------------------------------------------------------- /example-restful_server/workspace/demo1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/workspace/demo1.jpg -------------------------------------------------------------------------------- /example-restful_server/workspace/demo2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/workspace/demo2.jpg -------------------------------------------------------------------------------- /example-restful_server/workspace/favicon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/workspace/favicon.jpg -------------------------------------------------------------------------------- /example-restful_server/workspace/img.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/workspace/img.jpg -------------------------------------------------------------------------------- /example-restful_server/workspace/web/index.html: -------------------------------------------------------------------------------- 1 | Resful API
-------------------------------------------------------------------------------- /example-restful_server/workspace/web/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/workspace/web/static/favicon.ico -------------------------------------------------------------------------------- /example-restful_server/workspace/web/static/fonts/element-icons.535877f.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/workspace/web/static/fonts/element-icons.535877f.woff -------------------------------------------------------------------------------- /example-restful_server/workspace/web/static/fonts/element-icons.732389d.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/workspace/web/static/fonts/element-icons.732389d.ttf -------------------------------------------------------------------------------- /example-restful_server/workspace/web/static/fonts/iconfont.3eaa654.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/workspace/web/static/fonts/iconfont.3eaa654.woff -------------------------------------------------------------------------------- /example-restful_server/workspace/web/static/fonts/iconfont.88a8c82.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/workspace/web/static/fonts/iconfont.88a8c82.ttf -------------------------------------------------------------------------------- /example-restful_server/workspace/web/static/fonts/iconfont.cf057b5.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-restful_server/workspace/web/static/fonts/iconfont.cf057b5.eot -------------------------------------------------------------------------------- /example-restful_server/workspace/web/static/js/manifest.2ae2e69a05c33dfc65f8.js: -------------------------------------------------------------------------------- 1 | !function(r){var n=window.webpackJsonp;window.webpackJsonp=function(e,u,c){for(var f,i,p,a=0,l=[];a=2017) 10 | - [download the lean.rar](http://zifuture.com:1556/fs/sxai/lean.rar). 11 | 12 | *** 13 | 14 | # 关于依赖 15 | - CUDA10.1 (可修改,适配TensorRT即可) 16 | - CUDNN8.2.2.26 (可修改,适配 TensorRT即可) 17 | - OpenCV3.4.6 (可修改) 18 | - Protobuf3.11.4 (不可修改,否则问题多多) 19 | - TensorRT-8.0.1.6 20 | 21 | # 对于Windows而言 22 | - Visual Studio 2017 (请大于等于2017) 23 | - [点击下载打包好的lean.rar](http://zifuture.com:1556/fs/sxai/lean.rar) 24 | 25 | -------------------------------------------------------------------------------- /example-simple_yolo/simple_yolo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.902 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simple_yolo", "simple_yolo.vcxproj", "{01968AE1-519E-48CB-827B-E0D317B7707D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {01968AE1-519E-48CB-827B-E0D317B7707D}.Debug|x64.ActiveCfg = Debug|x64 17 | {01968AE1-519E-48CB-827B-E0D317B7707D}.Debug|x64.Build.0 = Debug|x64 18 | {01968AE1-519E-48CB-827B-E0D317B7707D}.Debug|x86.ActiveCfg = Debug|Win32 19 | {01968AE1-519E-48CB-827B-E0D317B7707D}.Debug|x86.Build.0 = Debug|Win32 20 | {01968AE1-519E-48CB-827B-E0D317B7707D}.Release|x64.ActiveCfg = Release|x64 21 | {01968AE1-519E-48CB-827B-E0D317B7707D}.Release|x64.Build.0 = Release|x64 22 | {01968AE1-519E-48CB-827B-E0D317B7707D}.Release|x86.ActiveCfg = Release|Win32 23 | {01968AE1-519E-48CB-827B-E0D317B7707D}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {87D7384D-E9D2-4F69-8099-77F1328568F7} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /example-simple_yolo/simple_yolo.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 头文件 20 | 21 | 22 | 23 | 24 | 源文件 25 | 26 | 27 | 源文件 28 | 29 | 30 | 31 | 32 | 源文件 33 | 34 | 35 | -------------------------------------------------------------------------------- /example-simple_yolo/simple_yolo.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | workspace 5 | PATH=$(projectDir)lean/cuda10.1/bin;$(projectDir)lean/opencv3.4.6/lib;$(projectDir)lean/cudnn8.2.2.26;$(projectDir)lean/TensorRT-8.0.1.6/lib 6 | WindowsLocalDebugger 7 | 8 | 9 | workspace 10 | PATH=$(projectDir)lean/cuda10.1/bin;$(projectDir)lean/opencv3.4.6/lib;$(projectDir)lean/cudnn8.2.2.26;$(projectDir)lean/TensorRT-8.0.1.6/lib 11 | WindowsLocalDebugger 12 | 13 | -------------------------------------------------------------------------------- /example-simple_yolo/src/import_lib.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 这个文件在windows下有效,linux下请忽略 3 | */ 4 | 5 | #if defined(_WIN32) 6 | # define U_OS_WINDOWS 7 | #else 8 | # define U_OS_LINUX 9 | #endif 10 | 11 | #ifdef U_OS_WINDOWS 12 | #if defined(_DEBUG) 13 | # pragma comment(lib, "opencv_world346d.lib") 14 | #else 15 | # pragma comment(lib, "opencv_world346.lib") 16 | #endif 17 | 18 | //导入cuda 19 | #pragma comment(lib, "cuda.lib") 20 | #pragma comment(lib, "cudart.lib") 21 | #pragma comment(lib, "cublas.lib") 22 | #pragma comment(lib, "cudnn.lib") 23 | 24 | //导入tensorRT 25 | #pragma comment(lib, "nvinfer.lib") 26 | #pragma comment(lib, "nvinfer_plugin.lib") 27 | #pragma comment(lib, "nvonnxparser.lib") 28 | 29 | #endif // U_OS_WINDOWS -------------------------------------------------------------------------------- /example-simple_yolo/workspace/fix_trt7.0_resize.py: -------------------------------------------------------------------------------- 1 | import onnx 2 | 3 | # pip install onnx 4 | # 如果你是TensorRT7.x,执行时一般会提示Resize节点无法解析,那么这个python文件可以解决解析的问题 5 | # 实现方案是把Resize修改为Upsample 6 | 7 | # https://github.com/onnx/onnx/blob/v1.2.1/onnx/onnx-ml.proto 8 | model = onnx.load("yolov5s-6.0.onnx") 9 | nodes = model.graph.node 10 | 11 | resize_layers = [ 12 | [index, node] for index, node in enumerate(nodes) if node.op_type == "Resize" 13 | ] 14 | 15 | ignore_constant = [] 16 | for index, layer in resize_layers: 17 | 18 | # will removed 19 | ignore_constant.append(layer.input[1]) 20 | 21 | upsample = onnx.NodeProto() 22 | attr_mode = onnx.AttributeProto() 23 | 24 | attr_mode.name = "mode" 25 | attr_mode.s = b"nearest" 26 | attr_mode.type = onnx.AttributeProto.AttributeType.STRING 27 | 28 | upsample.op_type = "Upsample" 29 | upsample.name = layer.name 30 | upsample.input.append(layer.input[0]) 31 | upsample.input.append(layer.input[2]) 32 | upsample.output.append(layer.output[0]) 33 | upsample.attribute.append(attr_mode) 34 | nodes[index].CopyFrom(upsample) 35 | 36 | for i in range(len(nodes)-1, -1, -1): 37 | for oname in nodes[i].output: 38 | if oname in ignore_constant: 39 | print(f"Remove node {nodes[i].name}") 40 | del nodes[i] 41 | break 42 | 43 | onnx.save(model, "yolov5s-6.0_upsample_dynamic.onnx") -------------------------------------------------------------------------------- /example-simple_yolo/workspace/infer_8.0.1.6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-simple_yolo/workspace/infer_8.0.1.6.jpg -------------------------------------------------------------------------------- /example-simple_yolo/workspace/inference/car.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-simple_yolo/workspace/inference/car.jpg -------------------------------------------------------------------------------- /example-simple_yolo/workspace/inference/gril.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-simple_yolo/workspace/inference/gril.jpg -------------------------------------------------------------------------------- /example-simple_yolo/workspace/inference/group.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-simple_yolo/workspace/inference/group.jpg -------------------------------------------------------------------------------- /example-simple_yolo/workspace/inference/yq.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-simple_yolo/workspace/inference/yq.jpg -------------------------------------------------------------------------------- /example-simple_yolo/workspace/inference/zand.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-simple_yolo/workspace/inference/zand.jpg -------------------------------------------------------------------------------- /example-simple_yolo/workspace/inference/zgjr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-simple_yolo/workspace/inference/zgjr.jpg -------------------------------------------------------------------------------- /lean/README.md: -------------------------------------------------------------------------------- 1 | # About dependencies 2 | - CUDA10.1 3 | - CUDNN8.2.2.26 4 | - OpenCV3.4.6 or 4.x 5 | - the above three are modifiable as long as being compatible to TensorRT 6 | - Protobuf3.11.4 7 | - tensorrt-8.0.1.6 8 | # For Windows 9 | - Visual Studio 2017 (>=2017) 10 | 11 | *** 12 | 13 | # 关于依赖 14 | - CUDA10.1 (可修改,适配TensorRT即可) 15 | - CUDNN8.2.2.26 (可修改,适配 TensorRT即可) 16 | - OpenCV3.4.6 (可修改) 17 | - Protobuf3.11.4 (可修改,若不同,请参照readme,尽量不要改) 18 | - TensorRT-8.0.1.6 19 | 20 | # 对于Windows而言 21 | - Visual Studio 2017 (请大于等于2017) 22 | 23 | # 直接下载lean.rar 24 | - 链接:https://pan.baidu.com/s/1DR21KgDBcgtScJPy3E94Fg 25 | - 提取码:sxai -------------------------------------------------------------------------------- /onnx/make_pb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 请修改protoc为你要使用的版本protoc 4 | protoc=/data/sxai/lean/protobuf3.11.4/bin/protoc 5 | #protoc=/data/sxai/temp/protobuf-build3.18.x/bin/protoc 6 | 7 | echo Create directory "pbout" 8 | rm -rf pbout 9 | mkdir -p pbout 10 | 11 | $protoc onnx-ml.proto --cpp_out=pbout 12 | $protoc onnx-operators-ml.proto --cpp_out=pbout 13 | 14 | echo Copy pbout/onnx-ml.pb.cc to ../src/tensorRT/onnx/onnx-ml.pb.cpp 15 | cp pbout/onnx-ml.pb.cc ../src/tensorRT/onnx/onnx-ml.pb.cpp 16 | 17 | echo Copy pbout/onnx-operators-ml.pb.cc to ../src/tensorRT/onnx/onnx-operators-ml.pb.cpp 18 | cp pbout/onnx-operators-ml.pb.cc ../src/tensorRT/onnx/onnx-operators-ml.pb.cpp 19 | 20 | echo Copy pbout/onnx-ml.pb.h to ../src/tensorRT/onnx/onnx-ml.pb.h 21 | cp pbout/onnx-ml.pb.h ../src/tensorRT/onnx/onnx-ml.pb.h 22 | 23 | echo Copy pbout/onnx-operators-ml.pb.h to ../src/tensorRT/onnx/onnx-operators-ml.pb.h 24 | cp pbout/onnx-operators-ml.pb.h ../src/tensorRT/onnx/onnx-operators-ml.pb.h 25 | 26 | echo Remove directory "pbout" 27 | rm -rf pbout -------------------------------------------------------------------------------- /onnx_parser/change.log.md: -------------------------------------------------------------------------------- 1 | # 针对OnnxParser的修改记录 2 | 1. builtin_op_importers.cpp:28 3 | - 增加针对reshape层hook的函数支持register_layerhook_reshape 4 | 2. builtin_op_importers.cpp:3543 5 | - 增加reshape节点中调用g_layerhook_func_reshape函数部分,使得hook生效 6 | 3. onnx_parser_7.x: builtin_op_importers.cpp:1629, onnx_parser_8.x builtin_op_importers.cpp:168 7 | - 增加Plugin节点支持,并转发到自定义的plugin上实现自定义插件注册机制 8 | 4. builtin_op_importers.cpp:4480 9 | - 对upsample屏蔽代码,并允许支持scales为3个值的情况 10 | 5. ModelImporter.cpp:243 11 | - 增加对重定义维度的支持,并实现动态batch,固定batch维度为-1 12 | 6. ModelImporter.cpp:750 13 | - 增加对onnx数据直接做解析的支持 14 | 7. ModelImporter.hpp:29 15 | - 增加对定义维度的支持 16 | 8. ModelImporter.hpp:72 17 | - 增加对onnx文件数据解析的支持 18 | 9. NvOnnxParser.h:207 19 | - 增加对reshape钩子的支持,接口api 20 | 10. NvOnnxParser.h:228 21 | - 增加input_dims参数,支持对输入维度的重定义 22 | -------------------------------------------------------------------------------- /onnx_parser/onnx_parser_7.x/LoopHelpers.cpp: -------------------------------------------------------------------------------- 1 | #include "LoopHelpers.hpp" 2 | #include "onnx2trt_utils.hpp" 3 | 4 | namespace onnx2trt 5 | { 6 | 7 | nvinfer1::ITensor* addLoopCounter(IImporterContext* ctx, nvinfer1::ILoop* loop, int32_t initial) 8 | { 9 | nvinfer1::ITensor* initialTensor = addConstantScalar(ctx, initial, ::onnx::TensorProto::INT32, nvinfer1::Dims{1, 1})->getOutput(0); 10 | nvinfer1::ITensor* one = addConstantScalar(ctx, 1, ::onnx::TensorProto::INT32, nvinfer1::Dims{1, 1})->getOutput(0); 11 | 12 | auto counter = loop->addRecurrence(*initialTensor); 13 | nvinfer1::ITensor* addOne = ctx->network()->addElementWise(*counter->getOutput(0), *one, nvinfer1::ElementWiseOperation::kSUM)->getOutput(0); 14 | counter->setInput(1, *addOne); 15 | return counter->getOutput(0); 16 | } 17 | 18 | } // namespace onnx2trt 19 | -------------------------------------------------------------------------------- /onnx_parser/onnx_parser_7.x/LoopHelpers.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "ImporterContext.hpp" 6 | 7 | namespace onnx2trt 8 | { 9 | 10 | nvinfer1::ITensor* addLoopCounter(IImporterContext* ctx, nvinfer1::ILoop* loop, int32_t initial = 0); 11 | 12 | } // namespace onnx2trt 13 | -------------------------------------------------------------------------------- /onnx_parser/onnx_parser_7.x/NvOnnxParser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #include "NvOnnxParser.h" 24 | #include "ModelImporter.hpp" 25 | 26 | extern "C" void* createNvOnnxParser_INTERNAL(void* network_, void* logger_, int version, const std::vector& input_dims) 27 | { 28 | auto network = static_cast(network_); 29 | auto logger = static_cast(logger_); 30 | return new onnx2trt::ModelImporter(network, logger, input_dims); 31 | } 32 | 33 | extern "C" int getNvOnnxParserVersion() 34 | { 35 | return NV_ONNX_PARSER_VERSION; 36 | } 37 | -------------------------------------------------------------------------------- /onnx_parser/onnx_parser_7.x/builtin_op_importers.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #pragma once 24 | 25 | #include "onnx2trt.hpp" 26 | #include "utils.hpp" 27 | 28 | namespace onnx2trt 29 | { 30 | 31 | string_map& getBuiltinOpImporterMap(); 32 | 33 | } // namespace onnx2trt 34 | -------------------------------------------------------------------------------- /onnx_parser/onnx_parser_7.x/onnx2trt_runtime.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #pragma once 24 | 25 | #include "onnx2trt_common.hpp" 26 | 27 | namespace onnx2trt 28 | { 29 | 30 | typedef Plugin* (*plugin_deserializer)(const void* serialData, size_t serialLength); 31 | 32 | } // namespace onnx2trt 33 | -------------------------------------------------------------------------------- /onnx_parser/onnx_parser_7.x/utils.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | template 28 | using string_map = std::unordered_map; 29 | -------------------------------------------------------------------------------- /onnx_parser/onnx_parser_8.x/LoopHelpers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #include "LoopHelpers.hpp" 6 | #include "onnx2trt_utils.hpp" 7 | 8 | namespace onnx2trt 9 | { 10 | 11 | nvinfer1::ITensor* addLoopCounter(IImporterContext* ctx, nvinfer1::ILoop* loop, int32_t initial) 12 | { 13 | nvinfer1::ITensor* initialTensor = addConstantScalar(ctx, initial, ::onnx::TensorProto::INT32, nvinfer1::Dims{1, 1})->getOutput(0); 14 | nvinfer1::ITensor* one = addConstantScalar(ctx, 1, ::onnx::TensorProto::INT32, nvinfer1::Dims{1, 1})->getOutput(0); 15 | 16 | auto counter = loop->addRecurrence(*initialTensor); 17 | nvinfer1::ITensor* addOne = ctx->network()->addElementWise(*counter->getOutput(0), *one, nvinfer1::ElementWiseOperation::kSUM)->getOutput(0); 18 | counter->setInput(1, *addOne); 19 | return counter->getOutput(0); 20 | } 21 | 22 | } // namespace onnx2trt 23 | -------------------------------------------------------------------------------- /onnx_parser/onnx_parser_8.x/LoopHelpers.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include "ImporterContext.hpp" 10 | 11 | namespace onnx2trt 12 | { 13 | 14 | nvinfer1::ITensor* addLoopCounter(IImporterContext* ctx, nvinfer1::ILoop* loop, int32_t initial = 0); 15 | 16 | } // namespace onnx2trt 17 | -------------------------------------------------------------------------------- /onnx_parser/onnx_parser_8.x/NvOnnxParser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #include "NvOnnxParser.h" 6 | #include "ModelImporter.hpp" 7 | 8 | extern "C" void* createNvOnnxParser_INTERNAL(void* network_, void* logger_, int version, const std::vector& input_dims) 9 | { 10 | auto network = static_cast(network_); 11 | auto logger = static_cast(logger_); 12 | return new onnx2trt::ModelImporter(network, logger, input_dims); 13 | } 14 | 15 | extern "C" int getNvOnnxParserVersion() 16 | { 17 | return NV_ONNX_PARSER_VERSION; 18 | } -------------------------------------------------------------------------------- /onnx_parser/onnx_parser_8.x/OnnxAttrs.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "ImporterContext.hpp" 13 | 14 | class OnnxAttrs 15 | { 16 | template 17 | using string_map = std::unordered_map; 18 | typedef string_map<::onnx::AttributeProto const*> AttrMap; 19 | AttrMap _attrs; 20 | onnx2trt::IImporterContext* mCtx; 21 | 22 | public: 23 | explicit OnnxAttrs(::onnx::NodeProto const& onnx_node, onnx2trt::IImporterContext* ctx) 24 | : mCtx{ctx} 25 | { 26 | for (auto const& attr : onnx_node.attribute()) 27 | { 28 | _attrs.insert({attr.name(), &attr}); 29 | } 30 | } 31 | 32 | bool count(const std::string& key) const 33 | { 34 | return _attrs.count(key); 35 | } 36 | 37 | ::onnx::AttributeProto const* at(std::string key) const 38 | { 39 | if (!_attrs.count(key)) 40 | { 41 | throw std::out_of_range("Attribute not found: " + key); 42 | } 43 | return _attrs.at(key); 44 | } 45 | 46 | ::onnx::AttributeProto::AttributeType type(const std::string& key) const 47 | { 48 | return this->at(key)->type(); 49 | } 50 | 51 | 52 | template 53 | T get(const std::string& key) const; 54 | 55 | template 56 | T get(const std::string& key, T const& default_value) const 57 | { 58 | return _attrs.count(key) ? this->get(key) : default_value; 59 | } 60 | }; 61 | -------------------------------------------------------------------------------- /onnx_parser/onnx_parser_8.x/ShapedWeights.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | namespace onnx2trt 11 | { 12 | 13 | class ShapedWeights 14 | { 15 | public: 16 | using DataType = int32_t; 17 | 18 | static ShapedWeights empty(DataType type); 19 | 20 | ShapedWeights(); 21 | 22 | explicit ShapedWeights(DataType type, void* values, nvinfer1::Dims shape_); 23 | 24 | size_t count() const; 25 | 26 | size_t size_bytes() const; 27 | 28 | const char* getName() const; 29 | 30 | void setName(const char* name); 31 | 32 | explicit operator bool() const; 33 | 34 | operator nvinfer1::Weights() const; 35 | 36 | template 37 | T& at(size_t index) 38 | { 39 | assert(index >= 0 && (index * sizeof(T)) < size_bytes()); 40 | return static_cast(values)[index]; 41 | } 42 | 43 | template 44 | const T& at(size_t index) const 45 | { 46 | assert(index >= 0 && (index * sizeof(T)) < size_bytes()); 47 | return static_cast(values)[index]; 48 | } 49 | 50 | public: 51 | DataType type; 52 | void* values; 53 | nvinfer1::Dims shape; 54 | const char* name{}; 55 | }; 56 | 57 | class IImporterContext; 58 | bool transposeWeights(ShapedWeights const& weights, nvinfer1::Permutation const& perm, ShapedWeights* result, IImporterContext* ctx); 59 | 60 | } // namespace onnx2trt 61 | -------------------------------------------------------------------------------- /onnx_parser/onnx_parser_8.x/builtin_op_importers.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "onnx2trt.hpp" 8 | #include "utils.hpp" 9 | 10 | namespace onnx2trt 11 | { 12 | 13 | string_map& getBuiltinOpImporterMap(); 14 | 15 | } // namespace onnx2trt 16 | -------------------------------------------------------------------------------- /onnx_parser/onnx_parser_8.x/onnx2trt_runtime.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "onnx2trt_common.hpp" 8 | 9 | namespace onnx2trt 10 | { 11 | 12 | typedef Plugin* (*plugin_deserializer)(const void* serialData, size_t serialLength); 13 | 14 | } // namespace onnx2trt 15 | -------------------------------------------------------------------------------- /onnx_parser/onnx_parser_8.x/readme.md: -------------------------------------------------------------------------------- 1 | # ONNX Parser 2 | - 这几个文件提取自官方的onnx-tensorrt,去掉python方面,其他都在 3 | - 另外增加了Plugin节点的支持 4 | - https://github.com/onnx/onnx-tensorrt -------------------------------------------------------------------------------- /onnx_parser/onnx_parser_8.x/utils.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | template 10 | using string_map = std::unordered_map; 11 | -------------------------------------------------------------------------------- /onnx_parser/readme.md: -------------------------------------------------------------------------------- 1 | # Onnx parser for 7.x/8.x 2 | - Origin Code 7.x: https://github.com/onnx/onnx-tensorrt/releases/tag/release%2F7.2.1 3 | - Origin Code 8.x: https://github.com/onnx/onnx-tensorrt/releases/tag/release%2F8.0 4 | 5 | # TensorRT 7.x support 6 | 1. Replace onnx_parser_for_7.x/onnx_parser to src/tensorRT/onnx_parser 7 | - `rm -rf src/tensorRT/onnx_parser` 8 | - `cp -r onnx_parser/onnx_parser_7.x src/tensorRT/onnx_parser` 9 | - or execute `bash onnx_parser/use_tensorrt_7.x.sh` 10 | 2. Configure Makefile/CMakeLists.txt path to TensorRT7.x 11 | 3. Execute `make yolo -j64` 12 | 13 | # TensorRT 8.x support 14 | 1. Replace onnx_parser_for_8.x/onnx_parser to src/tensorRT/onnx_parser 15 | - `rm -rf src/tensorRT/onnx_parser` 16 | - `cp -r onnx_parser/onnx_parser_8.x src/tensorRT/onnx_parser` 17 | - or execute `bash onnx_parser/use_tensorrt_8.x.sh` 18 | 2. Configure Makefile/CMakeLists.txt path to TensorRT8.x 19 | 3. Execute `make yolo -j64` 20 | 21 | # Unsupported TensorRT for less 7.x version -------------------------------------------------------------------------------- /onnx_parser/use_tensorrt_7.x.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo Remove src/tensorRT/onnx_parser 4 | rm -rf src/tensorRT/onnx_parser 5 | 6 | echo Copy [onnx_parser/onnx_parser_7.x] to [src/tensorRT/onnx_parser] 7 | cp -r onnx_parser/onnx_parser_7.x src/tensorRT/onnx_parser 8 | 9 | echo Configure your tensorRT path to 7.x 10 | echo After that, you can execute the command 'make yolo -j64' -------------------------------------------------------------------------------- /onnx_parser/use_tensorrt_8.x.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo Remove src/tensorRT/onnx_parser 4 | rm -rf src/tensorRT/onnx_parser 5 | 6 | echo Copy [onnx_parser/onnx_parser_8.x] to [src/tensorRT/onnx_parser] 7 | cp -r onnx_parser/onnx_parser_8.x src/tensorRT/onnx_parser 8 | 9 | echo Configure your tensorRT path to 8.x 10 | echo After that, you can execute the command 'make yolo -j64' -------------------------------------------------------------------------------- /src/application/app_alphapose_old/alpha_pose_old.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ALPHA_POSE_HPP 2 | #define ALPHA_POSE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | // based on https://github.com/MVIG-SJTU/AlphaPose v0.3.0 version 11 | namespace AlphaPoseOld{ 12 | 13 | using namespace std; 14 | using namespace cv; 15 | 16 | typedef tuple Input; 17 | 18 | class Infer{ 19 | public: 20 | virtual shared_future> commit(const Input& input) = 0; 21 | virtual vector>> commits(const vector& inputs) = 0; 22 | }; 23 | 24 | shared_ptr create_infer(const string& engine_file, int gpuid); 25 | 26 | }; // namespace AlphaPose 27 | 28 | #endif // ALPHA_POSE_HPP -------------------------------------------------------------------------------- /src/application/app_arcface/arcface.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ARCFACE_HPP 2 | #define ARCFACE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace Arcface{ 11 | 12 | using namespace std; 13 | 14 | struct landmarks{ 15 | float points[10]; 16 | }; 17 | 18 | typedef cv::Mat_ feature; 19 | typedef tuple commit_input; 20 | 21 | class Infer{ 22 | public: 23 | virtual shared_future commit (const commit_input& input) = 0; 24 | virtual vector> commits(const vector& inputs) = 0; 25 | }; 26 | 27 | cv::Mat face_alignment(const cv::Mat& image, const landmarks& landmark); 28 | shared_ptr create_infer(const string& engine_file, int gpuid=0); 29 | 30 | }; // namespace RetinaFace 31 | 32 | #endif // ARCFACE_HPP -------------------------------------------------------------------------------- /src/application/app_centernet/centernet.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CENTERNET_HPP 2 | #define CENTERNET_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace CenterNet{ 13 | 14 | using namespace std; 15 | using namespace ObjectDetector; 16 | 17 | void image_to_tensor(const cv::Mat& image, shared_ptr& tensor, int ibatch); 18 | 19 | class Infer{ 20 | public: 21 | virtual shared_future commit(const cv::Mat& image) = 0; 22 | virtual vector> commits(const vector& images) = 0; 23 | }; 24 | 25 | shared_ptr create_infer(const string& engine_file, int gpuid, float confidence_threshold=0.25f, float nms_threshold=0.5f); 26 | 27 | }; // namespace CenterNet 28 | 29 | 30 | #endif // CENTERNET_HPP -------------------------------------------------------------------------------- /src/application/app_dbface/dbface.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DBFACE_HPP 2 | #define DBFACE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace DBFace{ 13 | 14 | using namespace std; 15 | using namespace FaceDetector; 16 | 17 | void image_to_tensor(const cv::Mat& image, shared_ptr& tensor, int ibatch); 18 | 19 | class Infer{ 20 | public: 21 | virtual shared_future commit(const cv::Mat& image) = 0; 22 | virtual vector> commits(const vector& images) = 0; 23 | }; 24 | 25 | shared_ptr create_infer(const string& engine_file, int gpuid, float confidence_threshold=0.25f, float nms_threshold=0.5f); 26 | 27 | }; // namespace CenterNet 28 | 29 | 30 | #endif // DBFACE_HPP -------------------------------------------------------------------------------- /src/application/app_fall_gcn/fall_gcn.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FALL_GCN_HPP 2 | #define FALL_GCN_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace FallGCN{ 11 | 12 | using namespace std; 13 | using namespace cv; 14 | 15 | typedef tuple, Rect> Input; 16 | 17 | enum class FallState : int{ 18 | Fall = 0, 19 | Stand = 1, 20 | UnCertain = 2 21 | }; 22 | 23 | const char* state_name(FallState state); 24 | 25 | class Infer{ 26 | public: 27 | virtual shared_future> commit(const Input& input) = 0; 28 | virtual vector>> commits(const vector& inputs) = 0; 29 | }; 30 | 31 | shared_ptr create_infer(const string& engine_file, int gpuid); 32 | 33 | }; // namespace AlphaPose 34 | 35 | #endif // FALL_GCN_HPP -------------------------------------------------------------------------------- /src/application/app_high_performance/alpha_pose_high_perf.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ALPHA_POSE_HIGH_PERF_HPP 2 | #define ALPHA_POSE_HIGH_PERF_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "high_performance.hpp" 10 | 11 | namespace AlphaPoseHighPerf{ 12 | 13 | using namespace std; 14 | using namespace cv; 15 | using namespace HighPerformance; 16 | 17 | typedef tuple Input; 18 | 19 | class PointArray : public Data, public vector{ 20 | public: 21 | SetupData(PointArray); 22 | }; 23 | 24 | class Infer{ 25 | public: 26 | virtual shared_future commit(const Input& input) = 0; 27 | virtual vector> commits(const vector& inputs) = 0; 28 | }; 29 | 30 | shared_ptr create_infer(const string& engine_file, int gpuid); 31 | 32 | }; // namespace AlphaPose 33 | 34 | #endif // ALPHA_POSE_HIGH_PERF_HPP -------------------------------------------------------------------------------- /src/application/app_high_performance/yolo_high_perf.hpp: -------------------------------------------------------------------------------- 1 | #ifndef YOLO_HIGHPERF_HPP 2 | #define YOLO_HIGHPERF_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "high_performance.hpp" 10 | 11 | /** 12 | * @brief 发挥极致的性能体验 13 | * 支持YoloX和YoloV5 14 | */ 15 | namespace YoloHighPerf{ 16 | 17 | using namespace std; 18 | using namespace HighPerformance; 19 | 20 | enum class Type : int{ 21 | V5 = 0, 22 | X = 1, 23 | V3 = 2, 24 | V7 = 3 25 | }; 26 | 27 | struct Box{ 28 | float left, top, right, bottom, confidence; 29 | int class_label; 30 | 31 | Box() = default; 32 | 33 | Box(float left, float top, float right, float bottom, float confidence, int class_label) 34 | :left(left), top(top), right(right), bottom(bottom), confidence(confidence), class_label(class_label){} 35 | }; 36 | 37 | class BoxArray : public Data, public vector{ 38 | public: 39 | SetupData(BoxArray); 40 | }; 41 | 42 | class Infer{ 43 | public: 44 | virtual shared_future commit(const cv::Mat& image) = 0; 45 | virtual vector> commits(const vector& images) = 0; 46 | }; 47 | 48 | shared_ptr create_infer(const string& engine_file, Type type, int gpuid, float confidence_threshold=0.25f, float nms_threshold=0.5f); 49 | const char* type_name(Type type); 50 | 51 | }; // namespace Yolo 52 | 53 | #endif // YOLO_HIGHPERF_HPP -------------------------------------------------------------------------------- /src/application/app_retinaface/retinaface.hpp: -------------------------------------------------------------------------------- 1 | #ifndef RETINAFACE_HPP 2 | #define RETINAFACE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "../common/face_detector.hpp" 10 | 11 | namespace RetinaFace{ 12 | 13 | using namespace std; 14 | using namespace FaceDetector; 15 | 16 | class Infer{ 17 | public: 18 | virtual shared_future commit(const cv::Mat& image) = 0; 19 | virtual vector> commits(const vector& images) = 0; 20 | 21 | }; 22 | 23 | tuple crop_face_and_landmark( 24 | const cv::Mat& image, const Box& box, float scale_box=1.5f 25 | ); 26 | 27 | shared_ptr create_infer(const string& engine_file, int gpuid, float confidence_threshold=0.5f, float nms_threshold=0.5f); 28 | 29 | }; // namespace RetinaFace 30 | 31 | #endif // RETINAFACE_HPP -------------------------------------------------------------------------------- /src/application/app_scrfd/scrfd.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SCRFD_HPP 2 | #define SCRFD_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "../common/face_detector.hpp" 10 | 11 | namespace Scrfd{ 12 | 13 | using namespace std; 14 | using namespace FaceDetector; 15 | 16 | class Infer{ 17 | public: 18 | virtual shared_future commit(const cv::Mat& image) = 0; 19 | virtual vector> commits(const vector& images) = 0; 20 | }; 21 | 22 | tuple crop_face_and_landmark( 23 | const cv::Mat& image, const Box& box, float scale_box=1.5f 24 | ); 25 | 26 | shared_ptr create_infer(const string& engine_file, int gpuid, float confidence_threshold=0.5f, float nms_threshold=0.5f); 27 | 28 | }; // namespace Scrfd 29 | 30 | #endif // SCRFD_HPP -------------------------------------------------------------------------------- /src/application/app_yolo/multi_gpu.hpp: -------------------------------------------------------------------------------- 1 | #ifndef YOLO_MULTI_GPU_HPP 2 | #define YOLO_MULTI_GPU_HPP 3 | 4 | #include "yolo.hpp" 5 | 6 | namespace Yolo{ 7 | 8 | class MultiGPUInfer : public Yolo::Infer{}; 9 | 10 | shared_ptr create_multi_gpu_infer( 11 | const string& engine_file, Type type, const vector gpuids, 12 | float confidence_threshold=0.25f, float nms_threshold=0.5f, 13 | NMSMethod nms_method = NMSMethod::FastGPU, int max_objects = 1024 14 | ); 15 | }; 16 | 17 | 18 | #endif // YOLO_MULTI_GPU_HPP -------------------------------------------------------------------------------- /src/application/app_yolo/yolo.hpp: -------------------------------------------------------------------------------- 1 | #ifndef YOLO_HPP 2 | #define YOLO_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * @brief 发挥极致的性能体验 14 | * 支持YoloX和YoloV5 15 | */ 16 | namespace Yolo{ 17 | 18 | using namespace std; 19 | using namespace ObjectDetector; 20 | 21 | enum class Type : int{ 22 | V5 = 0, 23 | X = 1, 24 | V3 = 2, 25 | V7 = 3 26 | }; 27 | 28 | enum class NMSMethod : int{ 29 | CPU = 0, // General, for estimate mAP 30 | FastGPU = 1 // Fast NMS with a small loss of accuracy in corner cases 31 | }; 32 | 33 | void image_to_tensor(const cv::Mat& image, shared_ptr& tensor, Type type, int ibatch); 34 | 35 | class Infer{ 36 | public: 37 | virtual shared_future commit(const cv::Mat& image) = 0; 38 | virtual vector> commits(const vector& images) = 0; 39 | }; 40 | 41 | shared_ptr create_infer( 42 | const string& engine_file, Type type, int gpuid, 43 | float confidence_threshold=0.25f, float nms_threshold=0.5f, 44 | NMSMethod nms_method = NMSMethod::FastGPU, int max_objects = 1024, 45 | bool use_multi_preprocess_stream = false 46 | ); 47 | const char* type_name(Type type); 48 | 49 | }; // namespace Yolo 50 | 51 | #endif // YOLO_HPP -------------------------------------------------------------------------------- /src/application/app_yolo_fast/yolo_fast.hpp: -------------------------------------------------------------------------------- 1 | #ifndef YOLO_FAST_HPP 2 | #define YOLO_FAST_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * @brief 发挥极致的性能体验 14 | * 支持YoloX和YoloV5 15 | */ 16 | namespace YoloFast{ 17 | 18 | using namespace std; 19 | using namespace ObjectDetector; 20 | 21 | enum class Type : int{ 22 | V5_P5 = 0, 23 | V5_P6 = 1, 24 | X = 2 25 | }; 26 | 27 | struct DecodeMeta{ 28 | int num_anchor; 29 | int num_level; 30 | float w[16], h[16]; 31 | int strides[16]; 32 | 33 | static DecodeMeta v5_p5_default_meta(); 34 | static DecodeMeta v5_p6_default_meta(); 35 | static DecodeMeta x_default_meta(); 36 | }; 37 | 38 | class Infer{ 39 | public: 40 | virtual shared_future commit(const cv::Mat& image) = 0; 41 | virtual vector> commits(const vector& images) = 0; 42 | }; 43 | 44 | void image_to_tensor(const cv::Mat& image, shared_ptr& tensor, Type type, int ibatch); 45 | 46 | shared_ptr create_infer( 47 | const string& engine_file, 48 | Type type, 49 | int gpuid, 50 | float confidence_threshold=0.25f, 51 | float nms_threshold=0.5f, 52 | const DecodeMeta& meta = DecodeMeta::v5_p5_default_meta() 53 | ); 54 | const char* type_name(Type type); 55 | 56 | }; // namespace YoloFast 57 | 58 | #endif // YOLO_FAST_HPP -------------------------------------------------------------------------------- /src/application/common/face_detector.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FACE_DETECTOR_HPP 2 | #define FACE_DETECTOR_HPP 3 | 4 | #include 5 | #include 6 | 7 | namespace FaceDetector{ 8 | 9 | struct Box{ 10 | float left, top, right, bottom, confidence; 11 | float landmark[10]; 12 | 13 | cv::Rect cvbox() const{return cv::Rect(left, top, right-left, bottom-top);} 14 | float width() const{return std::max(0.0f, right-left);} 15 | float height() const{return std::max(0.0f, bottom-top);} 16 | float area() const{return width() * height();} 17 | float get_left() {return left;} 18 | void set_left(float value) {left = value;} 19 | float get_top() {return top;} 20 | void set_top(float value) {top = value;} 21 | float get_right() {return right;} 22 | void set_right(float value) {right = value;} 23 | float get_bottom() {return bottom;} 24 | void set_bottom(float value) {bottom = value;} 25 | float get_confidence() {return confidence;} 26 | void set_confidence(float value){confidence = value;} 27 | }; 28 | 29 | typedef std::vector BoxArray; 30 | }; 31 | 32 | #endif // FACE_DETECTOR_HPP -------------------------------------------------------------------------------- /src/application/common/object_detector.hpp: -------------------------------------------------------------------------------- 1 | #ifndef OBJECT_DETECTOR_HPP 2 | #define OBJECT_DETECTOR_HPP 3 | 4 | #include 5 | 6 | namespace ObjectDetector{ 7 | 8 | struct Box{ 9 | float left, top, right, bottom, confidence; 10 | int class_label; 11 | 12 | Box() = default; 13 | 14 | Box(float left, float top, float right, float bottom, float confidence, int class_label) 15 | :left(left), top(top), right(right), bottom(bottom), confidence(confidence), class_label(class_label){} 16 | }; 17 | 18 | typedef std::vector BoxArray; 19 | }; 20 | 21 | 22 | #endif // OBJECT_DETECTOR_HPP -------------------------------------------------------------------------------- /src/application/tools/Eigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(RegexUtils) 2 | test_escape_string_as_regex() 3 | 4 | file(GLOB Eigen_directory_files "*") 5 | 6 | escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 7 | 8 | foreach(f ${Eigen_directory_files}) 9 | if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/src") 10 | list(APPEND Eigen_directory_files_to_install ${f}) 11 | endif() 12 | endforeach(f ${Eigen_directory_files}) 13 | 14 | install(FILES 15 | ${Eigen_directory_files_to_install} 16 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel 17 | ) 18 | 19 | install(DIRECTORY src DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel FILES_MATCHING PATTERN "*.h") 20 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/Cholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_CHOLESKY_MODULE_H 9 | #define EIGEN_CHOLESKY_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Cholesky_Module Cholesky module 16 | * 17 | * 18 | * 19 | * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices. 20 | * Those decompositions are also accessible via the following methods: 21 | * - MatrixBase::llt() 22 | * - MatrixBase::ldlt() 23 | * - SelfAdjointView::llt() 24 | * - SelfAdjointView::ldlt() 25 | * 26 | * \code 27 | * #include 28 | * \endcode 29 | */ 30 | 31 | #include "src/Cholesky/LLT.h" 32 | #include "src/Cholesky/LDLT.h" 33 | #ifdef EIGEN_USE_LAPACKE 34 | #include "src/misc/lapacke.h" 35 | #include "src/Cholesky/LLT_LAPACKE.h" 36 | #endif 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_CHOLESKY_MODULE_H 41 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 42 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/Dense: -------------------------------------------------------------------------------- 1 | #include "Core" 2 | #include "LU" 3 | #include "Cholesky" 4 | #include "QR" 5 | #include "SVD" 6 | #include "Geometry" 7 | #include "Eigenvalues" 8 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/Eigen: -------------------------------------------------------------------------------- 1 | #include "Dense" 2 | #include "Sparse" 3 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/Householder: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_HOUSEHOLDER_MODULE_H 9 | #define EIGEN_HOUSEHOLDER_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Householder_Module Householder module 16 | * This module provides Householder transformations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | */ 22 | 23 | #include "src/Householder/Householder.h" 24 | #include "src/Householder/HouseholderSequence.h" 25 | #include "src/Householder/BlockHouseholder.h" 26 | 27 | #include "src/Core/util/ReenableStupidWarnings.h" 28 | 29 | #endif // EIGEN_HOUSEHOLDER_MODULE_H 30 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 31 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/Jacobi: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_JACOBI_MODULE_H 9 | #define EIGEN_JACOBI_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Jacobi_Module Jacobi module 16 | * This module provides Jacobi and Givens rotations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | * 22 | * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation: 23 | * - MatrixBase::applyOnTheLeft() 24 | * - MatrixBase::applyOnTheRight(). 25 | */ 26 | 27 | #include "src/Jacobi/Jacobi.h" 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif // EIGEN_JACOBI_MODULE_H 32 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 33 | 34 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/LU: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_LU_MODULE_H 9 | #define EIGEN_LU_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup LU_Module LU module 16 | * This module includes %LU decomposition and related notions such as matrix inversion and determinant. 17 | * This module defines the following MatrixBase methods: 18 | * - MatrixBase::inverse() 19 | * - MatrixBase::determinant() 20 | * 21 | * \code 22 | * #include 23 | * \endcode 24 | */ 25 | 26 | #include "src/misc/Kernel.h" 27 | #include "src/misc/Image.h" 28 | #include "src/LU/FullPivLU.h" 29 | #include "src/LU/PartialPivLU.h" 30 | #ifdef EIGEN_USE_LAPACKE 31 | #include "src/misc/lapacke.h" 32 | #include "src/LU/PartialPivLU_LAPACKE.h" 33 | #endif 34 | #include "src/LU/Determinant.h" 35 | #include "src/LU/InverseImpl.h" 36 | 37 | // Use the SSE optimized version whenever possible. At the moment the 38 | // SSE version doesn't compile when AVX is enabled 39 | #if defined EIGEN_VECTORIZE_SSE && !defined EIGEN_VECTORIZE_AVX 40 | #include "src/LU/arch/Inverse_SSE.h" 41 | #endif 42 | 43 | #include "src/Core/util/ReenableStupidWarnings.h" 44 | 45 | #endif // EIGEN_LU_MODULE_H 46 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 47 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/MetisSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_METISSUPPORT_MODULE_H 9 | #define EIGEN_METISSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | 20 | /** \ingroup Support_modules 21 | * \defgroup MetisSupport_Module MetisSupport module 22 | * 23 | * \code 24 | * #include 25 | * \endcode 26 | * This module defines an interface to the METIS reordering package (http://glaros.dtc.umn.edu/gkhome/views/metis). 27 | * It can be used just as any other built-in method as explained in \link OrderingMethods_Module here. \endlink 28 | */ 29 | 30 | 31 | #include "src/MetisSupport/MetisSupport.h" 32 | 33 | #include "src/Core/util/ReenableStupidWarnings.h" 34 | 35 | #endif // EIGEN_METISSUPPORT_MODULE_H 36 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/PardisoSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_PARDISOSUPPORT_MODULE_H 9 | #define EIGEN_PARDISOSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include 16 | 17 | /** \ingroup Support_modules 18 | * \defgroup PardisoSupport_Module PardisoSupport module 19 | * 20 | * This module brings support for the Intel(R) MKL PARDISO direct sparse solvers. 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * In order to use this module, the MKL headers must be accessible from the include paths, and your binary must be linked to the MKL library and its dependencies. 27 | * See this \ref TopicUsingIntelMKL "page" for more information on MKL-Eigen integration. 28 | * 29 | */ 30 | 31 | #include "src/PardisoSupport/PardisoSupport.h" 32 | 33 | #include "src/Core/util/ReenableStupidWarnings.h" 34 | 35 | #endif // EIGEN_PARDISOSUPPORT_MODULE_H 36 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/QR: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_QR_MODULE_H 9 | #define EIGEN_QR_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "Cholesky" 16 | #include "Jacobi" 17 | #include "Householder" 18 | 19 | /** \defgroup QR_Module QR module 20 | * 21 | * 22 | * 23 | * This module provides various QR decompositions 24 | * This module also provides some MatrixBase methods, including: 25 | * - MatrixBase::householderQr() 26 | * - MatrixBase::colPivHouseholderQr() 27 | * - MatrixBase::fullPivHouseholderQr() 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | */ 33 | 34 | #include "src/QR/HouseholderQR.h" 35 | #include "src/QR/FullPivHouseholderQR.h" 36 | #include "src/QR/ColPivHouseholderQR.h" 37 | #include "src/QR/CompleteOrthogonalDecomposition.h" 38 | #ifdef EIGEN_USE_LAPACKE 39 | #include "src/misc/lapacke.h" 40 | #include "src/QR/HouseholderQR_LAPACKE.h" 41 | #include "src/QR/ColPivHouseholderQR_LAPACKE.h" 42 | #endif 43 | 44 | #include "src/Core/util/ReenableStupidWarnings.h" 45 | 46 | #endif // EIGEN_QR_MODULE_H 47 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 48 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/QtAlignedMalloc: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_QTMALLOC_MODULE_H 9 | #define EIGEN_QTMALLOC_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #if (!EIGEN_MALLOC_ALREADY_ALIGNED) 14 | 15 | #include "src/Core/util/DisableStupidWarnings.h" 16 | 17 | void *qMalloc(std::size_t size) 18 | { 19 | return Eigen::internal::aligned_malloc(size); 20 | } 21 | 22 | void qFree(void *ptr) 23 | { 24 | Eigen::internal::aligned_free(ptr); 25 | } 26 | 27 | void *qRealloc(void *ptr, std::size_t size) 28 | { 29 | void* newPtr = Eigen::internal::aligned_malloc(size); 30 | memcpy(newPtr, ptr, size); 31 | Eigen::internal::aligned_free(ptr); 32 | return newPtr; 33 | } 34 | 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif 38 | 39 | #endif // EIGEN_QTMALLOC_MODULE_H 40 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 41 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/SPQRSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPQRSUPPORT_MODULE_H 9 | #define EIGEN_SPQRSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "SuiteSparseQR.hpp" 16 | 17 | /** \ingroup Support_modules 18 | * \defgroup SPQRSupport_Module SuiteSparseQR module 19 | * 20 | * This module provides an interface to the SPQR library, which is part of the suitesparse package. 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * In order to use this module, the SPQR headers must be accessible from the include paths, and your binary must be linked to the SPQR library and its dependencies (Cholmod, AMD, COLAMD,...). 27 | * For a cmake based project, you can use our FindSPQR.cmake and FindCholmod.Cmake modules 28 | * 29 | */ 30 | 31 | #include "src/CholmodSupport/CholmodSupport.h" 32 | #include "src/SPQRSupport/SuiteSparseQRSupport.h" 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/SVD: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SVD_MODULE_H 9 | #define EIGEN_SVD_MODULE_H 10 | 11 | #include "QR" 12 | #include "Householder" 13 | #include "Jacobi" 14 | 15 | #include "src/Core/util/DisableStupidWarnings.h" 16 | 17 | /** \defgroup SVD_Module SVD module 18 | * 19 | * 20 | * 21 | * This module provides SVD decomposition for matrices (both real and complex). 22 | * Two decomposition algorithms are provided: 23 | * - JacobiSVD implementing two-sided Jacobi iterations is numerically very accurate, fast for small matrices, but very slow for larger ones. 24 | * - BDCSVD implementing a recursive divide & conquer strategy on top of an upper-bidiagonalization which remains fast for large problems. 25 | * These decompositions are accessible via the respective classes and following MatrixBase methods: 26 | * - MatrixBase::jacobiSvd() 27 | * - MatrixBase::bdcSvd() 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | */ 33 | 34 | #include "src/misc/RealSvd2x2.h" 35 | #include "src/SVD/UpperBidiagonalization.h" 36 | #include "src/SVD/SVDBase.h" 37 | #include "src/SVD/JacobiSVD.h" 38 | #include "src/SVD/BDCSVD.h" 39 | #if defined(EIGEN_USE_LAPACKE) && !defined(EIGEN_USE_LAPACKE_STRICT) 40 | #include "src/misc/lapacke.h" 41 | #include "src/SVD/JacobiSVD_LAPACKE.h" 42 | #endif 43 | 44 | #include "src/Core/util/ReenableStupidWarnings.h" 45 | 46 | #endif // EIGEN_SVD_MODULE_H 47 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 48 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/Sparse: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSE_MODULE_H 9 | #define EIGEN_SPARSE_MODULE_H 10 | 11 | /** \defgroup Sparse_Module Sparse meta-module 12 | * 13 | * Meta-module including all related modules: 14 | * - \ref SparseCore_Module 15 | * - \ref OrderingMethods_Module 16 | * - \ref SparseCholesky_Module 17 | * - \ref SparseLU_Module 18 | * - \ref SparseQR_Module 19 | * - \ref IterativeLinearSolvers_Module 20 | * 21 | \code 22 | #include 23 | \endcode 24 | */ 25 | 26 | #include "SparseCore" 27 | #include "OrderingMethods" 28 | #ifndef EIGEN_MPL2_ONLY 29 | #include "SparseCholesky" 30 | #endif 31 | #include "SparseLU" 32 | #include "SparseQR" 33 | #include "IterativeLinearSolvers" 34 | 35 | #endif // EIGEN_SPARSE_MODULE_H 36 | 37 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/SparseCholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2013 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSECHOLESKY_MODULE_H 11 | #define EIGEN_SPARSECHOLESKY_MODULE_H 12 | 13 | #include "SparseCore" 14 | #include "OrderingMethods" 15 | 16 | #include "src/Core/util/DisableStupidWarnings.h" 17 | 18 | /** 19 | * \defgroup SparseCholesky_Module SparseCholesky module 20 | * 21 | * This module currently provides two variants of the direct sparse Cholesky decomposition for selfadjoint (hermitian) matrices. 22 | * Those decompositions are accessible via the following classes: 23 | * - SimplicialLLt, 24 | * - SimplicialLDLt 25 | * 26 | * Such problems can also be solved using the ConjugateGradient solver from the IterativeLinearSolvers module. 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | */ 32 | 33 | #ifdef EIGEN_MPL2_ONLY 34 | #error The SparseCholesky module has nothing to offer in MPL2 only mode 35 | #endif 36 | 37 | #include "src/SparseCholesky/SimplicialCholesky.h" 38 | 39 | #ifndef EIGEN_MPL2_ONLY 40 | #include "src/SparseCholesky/SimplicialCholesky_impl.h" 41 | #endif 42 | 43 | #include "src/Core/util/ReenableStupidWarnings.h" 44 | 45 | #endif // EIGEN_SPARSECHOLESKY_MODULE_H 46 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/SparseQR: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSEQR_MODULE_H 9 | #define EIGEN_SPARSEQR_MODULE_H 10 | 11 | #include "SparseCore" 12 | #include "OrderingMethods" 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup SparseQR_Module SparseQR module 16 | * \brief Provides QR decomposition for sparse matrices 17 | * 18 | * This module provides a simplicial version of the left-looking Sparse QR decomposition. 19 | * The columns of the input matrix should be reordered to limit the fill-in during the 20 | * decomposition. Built-in methods (COLAMD, AMD) or external methods (METIS) can be used to this end. 21 | * See the \link OrderingMethods_Module OrderingMethods\endlink module for the list 22 | * of built-in and external ordering methods. 23 | * 24 | * \code 25 | * #include 26 | * \endcode 27 | * 28 | * 29 | */ 30 | 31 | #include "OrderingMethods" 32 | #include "src/SparseCore/SparseColEtree.h" 33 | #include "src/SparseQR/SparseQR.h" 34 | 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/StdDeque: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDDEQUE_MODULE_H 12 | #define EIGEN_STDDEQUE_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdDeque.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDDEQUE_MODULE_H 28 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/StdList: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Hauke Heibel 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_STDLIST_MODULE_H 11 | #define EIGEN_STDLIST_MODULE_H 12 | 13 | #include "Core" 14 | #include 15 | 16 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 17 | 18 | #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) 19 | 20 | #else 21 | 22 | #include "src/StlSupport/StdList.h" 23 | 24 | #endif 25 | 26 | #endif // EIGEN_STDLIST_MODULE_H 27 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/StdVector: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDVECTOR_MODULE_H 12 | #define EIGEN_STDVECTOR_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdVector.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDVECTOR_MODULE_H 28 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/UmfPackSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_UMFPACKSUPPORT_MODULE_H 9 | #define EIGEN_UMFPACKSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | /** \ingroup Support_modules 20 | * \defgroup UmfPackSupport_Module UmfPackSupport module 21 | * 22 | * This module provides an interface to the UmfPack library which is part of the suitesparse package. 23 | * It provides the following factorization class: 24 | * - class UmfPackLU: a multifrontal sequential LU factorization. 25 | * 26 | * \code 27 | * #include 28 | * \endcode 29 | * 30 | * In order to use this module, the umfpack headers must be accessible from the include paths, and your binary must be linked to the umfpack library and its dependencies. 31 | * The dependencies depend on how umfpack has been compiled. 32 | * For a cmake based project, you can use our FindUmfPack.cmake module to help you in this task. 33 | * 34 | */ 35 | 36 | #include "src/UmfPackSupport/UmfPackSupport.h" 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_UMFPACKSUPPORT_MODULE_H 41 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/src/Core/DiagonalProduct.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // Copyright (C) 2007-2009 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_DIAGONALPRODUCT_H 12 | #define EIGEN_DIAGONALPRODUCT_H 13 | 14 | namespace Eigen { 15 | 16 | /** \returns the diagonal matrix product of \c *this by the diagonal matrix \a diagonal. 17 | */ 18 | template 19 | template 20 | inline const Product 21 | MatrixBase::operator*(const DiagonalBase &a_diagonal) const 22 | { 23 | return Product(derived(),a_diagonal.derived()); 24 | } 25 | 26 | } // end namespace Eigen 27 | 28 | #endif // EIGEN_DIAGONALPRODUCT_H 29 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/src/Core/arch/AVX/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2015 Benoit Steiner 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TYPE_CASTING_AVX_H 11 | #define EIGEN_TYPE_CASTING_AVX_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | // For now we use SSE to handle integers, so we can't use AVX instructions to cast 18 | // from int to float 19 | template <> 20 | struct type_casting_traits { 21 | enum { 22 | VectorizedCast = 0, 23 | SrcCoeffRatio = 1, 24 | TgtCoeffRatio = 1 25 | }; 26 | }; 27 | 28 | template <> 29 | struct type_casting_traits { 30 | enum { 31 | VectorizedCast = 0, 32 | SrcCoeffRatio = 1, 33 | TgtCoeffRatio = 1 34 | }; 35 | }; 36 | 37 | 38 | 39 | template<> EIGEN_STRONG_INLINE Packet8i pcast(const Packet8f& a) { 40 | return _mm256_cvtps_epi32(a); 41 | } 42 | 43 | template<> EIGEN_STRONG_INLINE Packet8f pcast(const Packet8i& a) { 44 | return _mm256_cvtepi32_ps(a); 45 | } 46 | 47 | } // end namespace internal 48 | 49 | } // end namespace Eigen 50 | 51 | #endif // EIGEN_TYPE_CASTING_AVX_H 52 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/src/Core/functors/TernaryFunctors.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2016 Eugene Brevdo 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TERNARY_FUNCTORS_H 11 | #define EIGEN_TERNARY_FUNCTORS_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | //---------- associative ternary functors ---------- 18 | 19 | 20 | 21 | } // end namespace internal 22 | 23 | } // end namespace Eigen 24 | 25 | #endif // EIGEN_TERNARY_FUNCTORS_H 26 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/src/Core/util/NonMPL2.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_MPL2_ONLY 2 | #error Including non-MPL2 code in EIGEN_MPL2_ONLY mode 3 | #endif 4 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/src/Core/util/ReenableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_WARNINGS_DISABLED 2 | #undef EIGEN_WARNINGS_DISABLED 3 | 4 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 5 | #ifdef _MSC_VER 6 | #pragma warning( pop ) 7 | #elif defined __INTEL_COMPILER 8 | #pragma warning pop 9 | #elif defined __clang__ 10 | #pragma clang diagnostic pop 11 | #elif defined __GNUC__ && __GNUC__>=6 12 | #pragma GCC diagnostic pop 13 | #endif 14 | 15 | #if defined __NVCC__ 16 | // Don't reenable the diagnostic messages, as it turns out these messages need 17 | // to be disabled at the point of the template instantiation (i.e the user code) 18 | // otherwise they'll be triggered by nvcc. 19 | // #pragma diag_default code_is_unreachable 20 | // #pragma diag_default initialization_not_reachable 21 | // #pragma diag_default 2651 22 | // #pragma diag_default 2653 23 | #endif 24 | 25 | #endif 26 | 27 | #endif // EIGEN_WARNINGS_DISABLED 28 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/src/SparseCore/SparseFuzzy.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2014 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSE_FUZZY_H 11 | #define EIGEN_SPARSE_FUZZY_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | template 17 | bool SparseMatrixBase::isApprox(const SparseMatrixBase& other, const RealScalar &prec) const 18 | { 19 | const typename internal::nested_eval::type actualA(derived()); 20 | typename internal::conditional::type, 22 | const PlainObject>::type actualB(other.derived()); 23 | 24 | return (actualA - actualB).squaredNorm() <= prec * prec * numext::mini(actualA.squaredNorm(), actualB.squaredNorm()); 25 | } 26 | 27 | } // end namespace Eigen 28 | 29 | #endif // EIGEN_SPARSE_FUZZY_H 30 | -------------------------------------------------------------------------------- /src/application/tools/Eigen/src/misc/lapacke_mangling.h: -------------------------------------------------------------------------------- 1 | #ifndef LAPACK_HEADER_INCLUDED 2 | #define LAPACK_HEADER_INCLUDED 3 | 4 | #ifndef LAPACK_GLOBAL 5 | #if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_) 6 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 7 | #elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER) 8 | #define LAPACK_GLOBAL(lcname,UCNAME) UCNAME 9 | #elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE) 10 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname 11 | #else 12 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 13 | #endif 14 | #endif 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /src/application/tools/auto_download.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | bool requires(const char* name) { 8 | 9 | auto onnx_file = iLogger::format("%s.onnx", name); 10 | if (not iLogger::exists(onnx_file)) { 11 | INFO("Auto download %s", onnx_file.c_str()); 12 | system(iLogger::format("wget http://zifuture.com:1556/fs/25.shared/%s", onnx_file.c_str()).c_str()); 13 | } 14 | 15 | bool exists = iLogger::exists(onnx_file); 16 | if (not exists) { 17 | INFOE("Download %s failed", onnx_file.c_str()); 18 | } 19 | return exists; 20 | } -------------------------------------------------------------------------------- /src/application/tools/zmq_remote_show.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "zmq_remote_show.hpp" 3 | #include "zmq_u.hpp" 4 | #include 5 | 6 | using namespace std; 7 | 8 | class ZMQRemoteShowImpl : public ZMQRemoteShow{ 9 | public: 10 | bool listen(const char* url){ 11 | try{ 12 | context_.reset(new zmq::context_t()); 13 | socket_.reset(new zmq::socket_t(*context_.get(), zmq::socket_type::rep)); 14 | socket_->bind(url); 15 | return true; 16 | }catch(zmq::error_t err){ 17 | INFOE("ZMQ exception: %s", err.what()); 18 | socket_.reset(); 19 | context_.reset(); 20 | } 21 | return false; 22 | } 23 | 24 | virtual void post(const void* data, int size) override{ 25 | 26 | if(size < 1 || data == nullptr){ 27 | INFOE("Null data to post"); 28 | return; 29 | } 30 | 31 | zmq::message_t msg; 32 | socket_->recv(msg); 33 | socket_->send(zmq::message_t(data, size)); 34 | } 35 | 36 | virtual void post(const cv::Mat& image) override{ 37 | 38 | vector data; 39 | cv::imencode(".jpg", image, data); 40 | post(data.data(), data.size()); 41 | } 42 | 43 | private: 44 | shared_ptr context_; 45 | shared_ptr socket_; 46 | }; 47 | 48 | std::shared_ptr create_zmq_remote_show(const char* listen){ 49 | 50 | shared_ptr instance(new ZMQRemoteShowImpl()); 51 | if(!instance->listen(listen)){ 52 | instance.reset(); 53 | } 54 | return instance; 55 | } 56 | -------------------------------------------------------------------------------- /src/application/tools/zmq_remote_show.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef ZMQ_REMOTE_SHOW_HPP 4 | #define ZMQ_REMOTE_SHOW_HPP 5 | 6 | #include 7 | #include 8 | 9 | class ZMQRemoteShow{ 10 | public: 11 | virtual void post(const void* data, int size) = 0; 12 | virtual void post(const cv::Mat& image) = 0; 13 | }; 14 | 15 | std::shared_ptr create_zmq_remote_show(const char* listen="tcp://0.0.0.0:15556"); 16 | 17 | #endif // ZMQ_REMOTE_SHOW_HPP -------------------------------------------------------------------------------- /src/direct/direct_classifier.cpp: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * onnx导出项目在这里: 4 | * https://github.com/shouxieai/tensorrt-pro-sample-python-classifier 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | int direct_classifier(){ 12 | 13 | if(!iLogger::exists("classifier.onnx")){ 14 | INFOE("classifier.onnx not found, reference: https://github.com/shouxieai/tensorrt-pro-sample-python-classifier"); 15 | return -1; 16 | } 17 | 18 | TRT::set_device(0); 19 | if(!iLogger::exists("classifier.trtmodel")){ 20 | TRT::compile( 21 | TRT::Mode::FP32, 22 | 1, 23 | "classifier.onnx", 24 | "classifier.trtmodel" 25 | ); 26 | INFO("Compile done"); 27 | } 28 | 29 | auto engine = TRT::load_infer("classifier.trtmodel"); 30 | if(engine == nullptr){ 31 | INFOE("Engine is nullptr"); 32 | return -1; 33 | } 34 | 35 | auto image = cv::imread("dog.jpg"); 36 | float mean[] = {0.485, 0.456, 0.406}; 37 | float std[] = {0.229, 0.224, 0.225}; 38 | engine->input()->set_norm_mat(0, image, mean, std); 39 | engine->forward(); 40 | 41 | float* prob = engine->output()->cpu(); 42 | int num_classes = engine->output()->channel(); 43 | int predict_label = std::max_element(prob, prob + num_classes) - prob; 44 | auto labels = iLogger::split_string(iLogger::load_text_file("labels.imagenet.txt"), "\n"); 45 | auto predict_name = labels[predict_label]; 46 | float confidence = prob[predict_label]; 47 | 48 | INFO("Predict: %s, confidence = %f, label = %d", predict_name.c_str(), confidence, predict_label); 49 | return 0; 50 | } -------------------------------------------------------------------------------- /src/direct/direct_mae.cpp: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * onnx导出项目在这里: 4 | * https://github.com/shouxieai/MAE-pytorch 5 | * 实验mae的特征提取功能 6 | * Masked Autoencoders Are Scalable Vision Learners 7 | * 8 | * onnx下载: 9 | * 链接:https://pan.baidu.com/s/1r0e82KQj99ue7sNBawNvUQ 10 | * 提取码:sxai 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | int direct_mae(){ 18 | 19 | TRT::set_device(0); 20 | TRT::compile( 21 | TRT::Mode::FP32, 22 | 1, 23 | "mae.onnx", "mae.trtmodel" 24 | ); 25 | INFO("Done"); 26 | 27 | auto engine = TRT::load_infer("mae.trtmodel"); 28 | auto image = cv::imread("test.jpg"); 29 | cv::cvtColor(image, image, cv::COLOR_BGR2RGB); 30 | 31 | float mean[] = {0.485, 0.456, 0.406}; 32 | float std[] = {0.229, 0.224, 0.225}; 33 | engine->input()->set_norm_mat(0, image, mean, std); 34 | engine->forward(); 35 | 36 | std::cout << engine->output()->shape_string() << std::endl; 37 | engine->output()->save_to_file("test.binary"); 38 | return 0; 39 | } -------------------------------------------------------------------------------- /src/tensorRT/import_lib.cpp: -------------------------------------------------------------------------------- 1 |  2 | #if defined(_WIN32) 3 | # define U_OS_WINDOWS 4 | #else 5 | # define U_OS_LINUX 6 | #endif 7 | 8 | #ifdef U_OS_WINDOWS 9 | #if defined(_DEBUG) 10 | # pragma comment(lib, "opencv_world346d.lib") 11 | #else 12 | # pragma comment(lib, "opencv_world346.lib") 13 | #endif 14 | 15 | //导入cuda 16 | #pragma comment(lib, "cuda.lib") 17 | #pragma comment(lib, "cudart.lib") 18 | #pragma comment(lib, "cublas.lib") 19 | #pragma comment(lib, "cudnn.lib") 20 | 21 | //导入tensorRT 22 | #pragma comment(lib, "nvinfer.lib") 23 | #pragma comment(lib, "nvinfer_plugin.lib") 24 | //#pragma comment(lib, "nvparsers.lib") 25 | 26 | #if defined(_DEBUG) 27 | #pragma comment(lib, "libprotobufd.lib") 28 | #else 29 | #pragma comment(lib, "libprotobuf.lib") 30 | #endif 31 | 32 | #ifdef HAS_PYTHON 33 | #pragma comment(lib, "python37.lib") 34 | #endif 35 | 36 | #endif // U_OS_WINDOWS -------------------------------------------------------------------------------- /src/tensorRT/onnx/onnx_pb.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) ONNX Project Contributors. 2 | // Licensed under the MIT license. 3 | 4 | #ifndef ONNX_ONNX_PB_H 5 | #define ONNX_ONNX_PB_H 6 | 7 | // Defines ONNX_EXPORT and ONNX_IMPORT. On Windows, this corresponds to 8 | // different declarations (dllexport and dllimport). On Linux/Mac, it just 9 | // resolves to the same "default visibility" setting. 10 | #if defined(_MSC_VER) 11 | #if defined(ONNX_BUILD_SHARED_LIBS) || defined(ONNX_BUILD_MAIN_LIB) 12 | #define ONNX_EXPORT __declspec(dllexport) 13 | #define ONNX_IMPORT __declspec(dllimport) 14 | #else 15 | #define ONNX_EXPORT 16 | #define ONNX_IMPORT 17 | #endif 18 | #else 19 | #if defined(__GNUC__) 20 | #define ONNX_EXPORT __attribute__((__visibility__("default"))) 21 | #else 22 | #define ONNX_EXPORT 23 | #endif 24 | #define ONNX_IMPORT ONNX_EXPORT 25 | #endif 26 | 27 | // ONNX_API is a macro that, depends on whether you are building the 28 | // main ONNX library or not, resolves to either ONNX_EXPORT or 29 | // ONNX_IMPORT. 30 | // 31 | // This is used in e.g. ONNX's protobuf files: when building the main library, 32 | // it is defined as ONNX_EXPORT to fix a Windows global-variable-in-dll 33 | // issue, and for anyone dependent on ONNX it will be defined as 34 | // ONNX_IMPORT. ONNX_BUILD_MAIN_LIB can also be set when being built 35 | // statically if ONNX is being linked into a shared library that wants 36 | // to export the ONNX APIs and classes. 37 | // 38 | // More details on Windows dllimport / dllexport can be found at 39 | // https://msdn.microsoft.com/en-us/library/3y1sfaz2.aspx 40 | // 41 | // This solution is similar to 42 | // https://github.com/pytorch/pytorch/blob/master/caffe2/core/common.h 43 | #define ONNX_API 44 | #include "onnx-ml.pb.h" 45 | 46 | #endif // ! ONNX_ONNX_PB_H 47 | -------------------------------------------------------------------------------- /src/tensorRT/onnx/readme.md: -------------------------------------------------------------------------------- 1 | # ONNX 2 | - 这几个文件来自于对ONNX的编译后提取的结果,由protoc生成的cpp 3 | - https://github.com/onnx/onnx -------------------------------------------------------------------------------- /src/tensorRT/onnx_parser/LoopHelpers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #include "LoopHelpers.hpp" 6 | #include "onnx2trt_utils.hpp" 7 | 8 | namespace onnx2trt 9 | { 10 | 11 | nvinfer1::ITensor* addLoopCounter(IImporterContext* ctx, nvinfer1::ILoop* loop, int32_t initial) 12 | { 13 | nvinfer1::ITensor* initialTensor = addConstantScalar(ctx, initial, ::onnx::TensorProto::INT32, nvinfer1::Dims{1, 1})->getOutput(0); 14 | nvinfer1::ITensor* one = addConstantScalar(ctx, 1, ::onnx::TensorProto::INT32, nvinfer1::Dims{1, 1})->getOutput(0); 15 | 16 | auto counter = loop->addRecurrence(*initialTensor); 17 | nvinfer1::ITensor* addOne = ctx->network()->addElementWise(*counter->getOutput(0), *one, nvinfer1::ElementWiseOperation::kSUM)->getOutput(0); 18 | counter->setInput(1, *addOne); 19 | return counter->getOutput(0); 20 | } 21 | 22 | } // namespace onnx2trt 23 | -------------------------------------------------------------------------------- /src/tensorRT/onnx_parser/LoopHelpers.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include "ImporterContext.hpp" 10 | 11 | namespace onnx2trt 12 | { 13 | 14 | nvinfer1::ITensor* addLoopCounter(IImporterContext* ctx, nvinfer1::ILoop* loop, int32_t initial = 0); 15 | 16 | } // namespace onnx2trt 17 | -------------------------------------------------------------------------------- /src/tensorRT/onnx_parser/NvOnnxParser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #include "NvOnnxParser.h" 6 | #include "ModelImporter.hpp" 7 | 8 | extern "C" void* createNvOnnxParser_INTERNAL(void* network_, void* logger_, int version, const std::vector& input_dims) 9 | { 10 | auto network = static_cast(network_); 11 | auto logger = static_cast(logger_); 12 | return new onnx2trt::ModelImporter(network, logger, input_dims); 13 | } 14 | 15 | extern "C" int getNvOnnxParserVersion() 16 | { 17 | return NV_ONNX_PARSER_VERSION; 18 | } -------------------------------------------------------------------------------- /src/tensorRT/onnx_parser/OnnxAttrs.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "ImporterContext.hpp" 13 | 14 | class OnnxAttrs 15 | { 16 | template 17 | using string_map = std::unordered_map; 18 | typedef string_map<::onnx::AttributeProto const*> AttrMap; 19 | AttrMap _attrs; 20 | onnx2trt::IImporterContext* mCtx; 21 | 22 | public: 23 | explicit OnnxAttrs(::onnx::NodeProto const& onnx_node, onnx2trt::IImporterContext* ctx) 24 | : mCtx{ctx} 25 | { 26 | for (auto const& attr : onnx_node.attribute()) 27 | { 28 | _attrs.insert({attr.name(), &attr}); 29 | } 30 | } 31 | 32 | bool count(const std::string& key) const 33 | { 34 | return _attrs.count(key); 35 | } 36 | 37 | ::onnx::AttributeProto const* at(std::string key) const 38 | { 39 | if (!_attrs.count(key)) 40 | { 41 | throw std::out_of_range("Attribute not found: " + key); 42 | } 43 | return _attrs.at(key); 44 | } 45 | 46 | ::onnx::AttributeProto::AttributeType type(const std::string& key) const 47 | { 48 | return this->at(key)->type(); 49 | } 50 | 51 | 52 | template 53 | T get(const std::string& key) const; 54 | 55 | template 56 | T get(const std::string& key, T const& default_value) const 57 | { 58 | return _attrs.count(key) ? this->get(key) : default_value; 59 | } 60 | }; 61 | -------------------------------------------------------------------------------- /src/tensorRT/onnx_parser/ShapedWeights.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | namespace onnx2trt 11 | { 12 | 13 | class ShapedWeights 14 | { 15 | public: 16 | using DataType = int32_t; 17 | 18 | static ShapedWeights empty(DataType type); 19 | 20 | ShapedWeights(); 21 | 22 | explicit ShapedWeights(DataType type, void* values, nvinfer1::Dims shape_); 23 | 24 | size_t count() const; 25 | 26 | size_t size_bytes() const; 27 | 28 | const char* getName() const; 29 | 30 | void setName(const char* name); 31 | 32 | explicit operator bool() const; 33 | 34 | operator nvinfer1::Weights() const; 35 | 36 | template 37 | T& at(size_t index) 38 | { 39 | assert(index >= 0 && (index * sizeof(T)) < size_bytes()); 40 | return static_cast(values)[index]; 41 | } 42 | 43 | template 44 | const T& at(size_t index) const 45 | { 46 | assert(index >= 0 && (index * sizeof(T)) < size_bytes()); 47 | return static_cast(values)[index]; 48 | } 49 | 50 | public: 51 | DataType type; 52 | void* values; 53 | nvinfer1::Dims shape; 54 | const char* name{}; 55 | }; 56 | 57 | class IImporterContext; 58 | bool transposeWeights(ShapedWeights const& weights, nvinfer1::Permutation const& perm, ShapedWeights* result, IImporterContext* ctx); 59 | 60 | } // namespace onnx2trt 61 | -------------------------------------------------------------------------------- /src/tensorRT/onnx_parser/builtin_op_importers.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "onnx2trt.hpp" 8 | #include "utils.hpp" 9 | 10 | namespace onnx2trt 11 | { 12 | 13 | string_map& getBuiltinOpImporterMap(); 14 | 15 | } // namespace onnx2trt 16 | -------------------------------------------------------------------------------- /src/tensorRT/onnx_parser/onnx2trt_runtime.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "onnx2trt_common.hpp" 8 | 9 | namespace onnx2trt 10 | { 11 | 12 | typedef Plugin* (*plugin_deserializer)(const void* serialData, size_t serialLength); 13 | 14 | } // namespace onnx2trt 15 | -------------------------------------------------------------------------------- /src/tensorRT/onnx_parser/readme.md: -------------------------------------------------------------------------------- 1 | # ONNX Parser 2 | - 这几个文件提取自官方的onnx-tensorrt,去掉python方面,其他都在 3 | - 另外增加了Plugin节点的支持 4 | - https://github.com/onnx/onnx-tensorrt -------------------------------------------------------------------------------- /src/tensorRT/onnx_parser/utils.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | template 10 | using string_map = std::unordered_map; 11 | -------------------------------------------------------------------------------- /tools/show.py: -------------------------------------------------------------------------------- 1 | 2 | # 配合/data/sxai/tensorRT/src/application/app_fall_recognize.cpp中的zmq remote实现远程显示服务器画面的效果 3 | # pip install zmq 4 | import zmq 5 | import sys 6 | import numpy as np 7 | import cv2 8 | 9 | context = zmq.Context() 10 | socket = context.socket(zmq.REQ) 11 | socket.connect("tcp://192.168.16.109:15556") 12 | 13 | while True: 14 | socket.send(b"a") 15 | message = socket.recv() 16 | if len(message) == 1 and message == b'x': 17 | break 18 | 19 | image = np.frombuffer(message, dtype=np.uint8) 20 | image = cv2.imdecode(image, 1) 21 | 22 | cv2.imshow("image", image) 23 | key = cv2.waitKey(1) & 0xFF 24 | 25 | if key == ord('q'): 26 | break -------------------------------------------------------------------------------- /tools/test_dataloader_resize.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch.utils.data import DataLoader 3 | import pycuda_resize as pr 4 | import numpy as np 5 | import cv2 6 | 7 | class Dataset: 8 | def __getitem__(self, index): 9 | image = (np.random.rand(100, 100, 3) * 255).astype(np.uint8) 10 | opencv_resize = cv2.resize(image, (33, 33)) 11 | my_resize = pr.resize(image, (33, 33)) 12 | return opencv_resize, my_resize 13 | 14 | def __len__(self): 15 | return 10 16 | 17 | # reference: https://stackoverflow.com/a/55812288/8664574 18 | # 如果有spawn,必须保证得有if __name__ == "__main__":作为入口 19 | if __name__ == "__main__": 20 | 21 | # 这一句很关键,否则会报错cuda initialize failed 22 | torch.multiprocessing.set_start_method('spawn') 23 | dataset = Dataset() 24 | dataloader = DataLoader(dataset, 1, True, num_workers=2) 25 | 26 | for a, b in dataloader: 27 | absdiff = torch.abs(a.float() - b.float()) 28 | print(f"sum = {absdiff.sum().item()}, max = {absdiff.max().item()}, shape = {list(absdiff.shape)}") -------------------------------------------------------------------------------- /tools/test_resize.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | import pycuda_resize as pr 4 | 5 | image = (np.random.rand(100, 100, 3) * 255).astype(np.uint8) 6 | opencv_resize = cv2.resize(image, (5, 10)) 7 | my_resize = pr.resize(image, (5, 10)) 8 | abs_diff = np.abs(opencv_resize.astype(int) - my_resize.astype(int)) 9 | 10 | print("===========================abs diff==============================") 11 | print(abs_diff) 12 | 13 | print("\n\n") 14 | print("===========================OpenCV Resize==========================") 15 | print(opencv_resize) 16 | print("\n\n") 17 | print("============================My Resize============================") 18 | print(my_resize) 19 | 20 | -------------------------------------------------------------------------------- /tutorial/1.0framework/README.md: -------------------------------------------------------------------------------- 1 | EN 2 | - yolo_example is a complete example to demonstrate how the framework works. Configure it to src/application as a new app (e.g. app_tutorial) if you want to run it. pipeline.pdf and pipeline.goodnotes are resources for tutorial. Any more vivid images or notes are welcomed to make the framework better. 3 | 4 | ZH 5 | - Yolo_example是一个完整的示例,演示了框架是如何工作的。如果你想运行它,将它配置到src/application作为一个新应用(例如app_tutorial)。pipeline.pdf and pipeline.goodnotes 可以帮助大家更好的理解该框架的流程。 欢迎大家投稿自己的注释或绘画插图方便更多人使用我们的框架。 6 | -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/car.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/car.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_0.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_2.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_21.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_210.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_210.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_211.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_211.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_212.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_212.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_213.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_213.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_214.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_214.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_215.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_215.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_216.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_216.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_217.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_217.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_218.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_218.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_219.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_219.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_22.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_220.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_220.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_221.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_221.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_222.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_222.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_223.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_223.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_224.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_224.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_225.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_225.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_226.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_226.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_227.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_227.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_228.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_228.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_229.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_229.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_27.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_27.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_270.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_270.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_271.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_271.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_272.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_272.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_273.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_273.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_274.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_274.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_275.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_275.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_276.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_276.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_277.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_277.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_278.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_278.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_279.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_279.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_29.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_29.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_290.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_290.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_291.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_291.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_292.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_292.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_293.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_293.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_294.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_294.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_295.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_295.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_296.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_296.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_297.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_297.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_298.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_298.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/f3_299.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/f3_299.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/gril.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/gril.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/group.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/group.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/show.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/show.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/torch_affine.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/torch_affine.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/trt_affine.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/trt_affine.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/yq.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/yq.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/zand.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/zand.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/zand_copy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/zand_copy.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/inference/zgjr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/inference/zgjr.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/pipeline.goodnotes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/pipeline.goodnotes -------------------------------------------------------------------------------- /tutorial/1.0framework/pipeline.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/pipeline.jpg -------------------------------------------------------------------------------- /tutorial/1.0framework/pipeline.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/1.0framework/pipeline.pdf -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "./src/**", 7 | "/datav/shared/wkx/tensorRT_cpp/lean/protobuf3.11.4/include/**", 8 | "/usr/local/opencv/include/opencv4/**", 9 | "/usr/local/cuda/include/**", 10 | "/datav/shared/wkx/tensorRT_cpp/lean/TensorRT-8.0.1.6/include/**", 11 | "/datav/shared/wkx/tensorRT_cpp/lean/cudnn8.2.2.26/include/**", 12 | "/root/anaconda3/include/python3.8/**" 13 | ], 14 | "defines": ["__CUDACC__", "HAS_PYTHON"], 15 | "compilerPath": "/usr/bin/gcc", 16 | "cStandard": "gnu11", 17 | "cppStandard": "gnu++11", 18 | "intelliSenseMode": "linux-gcc-x64", 19 | "configurationProvider": "ms-vscode.makefile-tools", 20 | "browse": { 21 | "limitSymbolsToIncludedHeaders": false, 22 | "databaseFilename": "" 23 | } 24 | } 25 | ], 26 | "version": 4 27 | } -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | // run c++ 9 | { 10 | "name": "(gdb) 启动", 11 | "type": "cppdbg", 12 | "request": "launch", 13 | "program": "${workspaceFolder}/workspace/pro", 14 | "args": [ 15 | "centernet", 16 | ], 17 | "stopAtEntry": false, 18 | "cwd": "${workspaceFolder}/workspace", 19 | "environment": [], 20 | "externalConsole": false, 21 | "MIMode": "gdb", 22 | "setupCommands": [ 23 | { 24 | "description": "为 gdb 启用整齐打印", 25 | "text": "-enable-pretty-printing", 26 | "ignoreFailures": true 27 | } 28 | ], 29 | "preLaunchTask": "build" 30 | } 31 | ] 32 | } -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "build", 8 | "type": "shell", 9 | "command": "make pro -j25" 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/src/comments.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/src/comments.jpg -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/src/cuda_nms.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/src/cuda_nms.jpg -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int app_centernet(); 7 | 8 | int main(){ 9 | app_centernet(); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/affined_result_cpp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/affined_result_cpp.jpg -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/car.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/car.jpg -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/final_result_cpp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/final_result_cpp.jpg -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/final_result_cuda.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/final_result_cuda.jpg -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/cpp_cuda_centernet/workspace/test.jpg -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/model_output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/model_output -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/truck_and_person.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/2.0CenterNet_from_torch_trt/0_to_1_python_to_cuda/truck_and_person.jpg -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/5_outputs.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/2.0CenterNet_from_torch_trt/5_outputs.jpg -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/DCNmodule_res18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/2.0CenterNet_from_torch_trt/DCNmodule_res18.png -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/all_in_one_output.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/2.0CenterNet_from_torch_trt/all_in_one_output.jpg -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/comments.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/2.0CenterNet_from_torch_trt/comments.jpg -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/cuda_nms.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/2.0CenterNet_from_torch_trt/cuda_nms.jpg -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/demo.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import division 3 | from __future__ import print_function 4 | 5 | import _init_paths 6 | 7 | import os 8 | import cv2 9 | 10 | from opts import opts 11 | from detectors.detector_factory import detector_factory 12 | 13 | image_ext = ['jpg', 'jpeg', 'png', 'webp'] 14 | video_ext = ['mp4', 'mov', 'avi', 'mkv'] 15 | time_stats = ['tot', 'load', 'pre', 'net', 'dec', 'post', 'merge'] 16 | 17 | def demo(opt): 18 | os.environ['CUDA_VISIBLE_DEVICES'] = opt.gpus_str 19 | opt.debug = max(opt.debug, 1) 20 | Detector = detector_factory[opt.task] 21 | detector = Detector(opt) 22 | 23 | ret = detector.run("images/yq.jpg") 24 | time_str = '' 25 | for stat in time_stats: 26 | time_str = time_str + '{} {:.3f}s |'.format(stat, ret[stat]) 27 | print(time_str) 28 | if __name__ == '__main__': 29 | opt = opts().init() 30 | demo(opt) 31 | -------------------------------------------------------------------------------- /tutorial/2.0CenterNet_from_torch_trt/export2onnx.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import division 3 | from __future__ import print_function 4 | 5 | import _init_paths 6 | import torch 7 | 8 | import os 9 | import cv2 10 | 11 | from opts import opts 12 | from detectors.detector_factory import detector_factory 13 | 14 | if __name__ == '__main__': 15 | opt = opts().init() 16 | os.environ['CUDA_VISIBLE_DEVICES'] = opt.gpus_str 17 | opt.debug = max(opt.debug, 1) 18 | Detector = detector_factory[opt.task] 19 | detector = Detector(opt) 20 | 21 | model = detector.model.eval().to(opt.device) # Note that eval() should be set. 22 | 23 | dummy_input = torch.zeros((1, 3, 512, 512)).to(opt.device) 24 | 25 | """ 26 | note that if you are exporting onnx, you need to use the DCN for onnx rather than the original one(modify the dcn_v2.py). 27 | comment the original and uncomment the DU. Remember to fill in the args required. Or you can run it in debug mode where 28 | all required args have been filled in. 29 | """ 30 | torch.onnx.export( 31 | model, 32 | (dummy_input,), 33 | 'latest_ctnet_r18_dcn.onnx', 34 | input_names=["images"], 35 | # output_names=["regxy","wh","hm","pool_hm","output"], 36 | output_names=["output"], 37 | verbose=True, 38 | opset_version=11, 39 | # dynamic_axes={"images": {0:"batch"}, "regxy": {0:"batch"}, "wh": {0:"batch"}, 40 | # "hm": {0:"batch"}, "pool_hm": {0:"batch"}, 41 | # "output":{0:"batch"}}, 42 | dynamic_axes={"images": {0:"batch"}, "output":{0:"batch"}}, 43 | enable_onnx_checker=False 44 | ) 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /tutorial/YoloTRT_speed.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/YoloTRT_speed.xlsx -------------------------------------------------------------------------------- /tutorial/ali-qr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/ali-qr.jpg -------------------------------------------------------------------------------- /tutorial/wechat-qr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/tutorial/wechat-qr.jpg -------------------------------------------------------------------------------- /windows/README.md: -------------------------------------------------------------------------------- 1 | # Windows support 2 | - 1. Move all files to ../ 3 | - 2. Open TensorRT.sln and build project. -------------------------------------------------------------------------------- /windows/TensorRT.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.136 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TensorRT", "TensorRT.vcxproj", "{FBF775F5-DAB4-4BC1-97A9-D36301073438}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Python|x64 = Python|x64 12 | Release|x64 = Release|x64 13 | EndGlobalSection 14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 15 | {FBF775F5-DAB4-4BC1-97A9-D36301073438}.Debug|x64.ActiveCfg = Debug|x64 16 | {FBF775F5-DAB4-4BC1-97A9-D36301073438}.Debug|x64.Build.0 = Debug|x64 17 | {FBF775F5-DAB4-4BC1-97A9-D36301073438}.Python|x64.ActiveCfg = Python|x64 18 | {FBF775F5-DAB4-4BC1-97A9-D36301073438}.Python|x64.Build.0 = Python|x64 19 | {FBF775F5-DAB4-4BC1-97A9-D36301073438}.Release|x64.ActiveCfg = Release|x64 20 | {FBF775F5-DAB4-4BC1-97A9-D36301073438}.Release|x64.Build.0 = Release|x64 21 | EndGlobalSection 22 | GlobalSection(SolutionProperties) = preSolution 23 | HideSolutionNode = FALSE 24 | EndGlobalSection 25 | GlobalSection(ExtensibilityGlobals) = postSolution 26 | SolutionGuid = {679F35F0-20AA-4D18-8610-D369E2BE97E8} 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /windows/TensorRT.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | workspace 5 | PATH=$(projectDir)lean/cuda10.1/bin;$(projectDir)lean/opencv3.4.6/lib;$(projectDir)lean/cudnn8.2.2.26;$(projectDir)lean/TensorRT-8.0.1.6/lib 6 | WindowsLocalDebugger 7 | true 8 | 9 | 10 | workspace 11 | PATH=$(projectDir)lean/cuda10.1/bin;$(projectDir)lean/opencv3.4.6/lib;$(projectDir)lean/cudnn8.2.2.26;$(projectDir)lean/TensorRT-8.0.1.6/lib 12 | WindowsLocalDebugger 13 | true 14 | 15 | 16 | WindowsLocalDebugger 17 | PATH=$(projectDir)lean/cuda10.1/bin;$(projectDir)lean/opencv3.4.6/lib;$(projectDir)lean/cudnn8.2.2.26;$(projectDir)lean/TensorRT-8.0.1.6/lib 18 | workspace 19 | 20 | -------------------------------------------------------------------------------- /windows/dll_export.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | PyInit_libpytrtc -------------------------------------------------------------------------------- /workspace/cvt_dbface.py: -------------------------------------------------------------------------------- 1 | import onnx 2 | 3 | # 下载的onnx的upsample节点是3个scales,需要修改为4个 4 | model = onnx.load("dbface.onnx") 5 | changed = False 6 | 7 | for n in model.graph.node: 8 | if n.op_type == "Upsample": 9 | if len(n.attribute[1].floats) == 3: 10 | changed = True 11 | n.attribute[1].floats.insert(0, 1.0) 12 | 13 | if changed: 14 | print("Change and save to dbface_cvt.onnx.") 15 | onnx.save(model, "dbface_cvt.onnx") 16 | else: 17 | print("No need change.") -------------------------------------------------------------------------------- /workspace/dog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/dog.jpg -------------------------------------------------------------------------------- /workspace/exp/face_tracker.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/exp/face_tracker.mp4 -------------------------------------------------------------------------------- /workspace/exp/fall_video.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/exp/fall_video.mp4 -------------------------------------------------------------------------------- /workspace/face/library/2ys2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/face/library/2ys2.jpg -------------------------------------------------------------------------------- /workspace/face/library/2ys3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/face/library/2ys3.jpg -------------------------------------------------------------------------------- /workspace/face/library/male.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/face/library/male.jpg -------------------------------------------------------------------------------- /workspace/face/recognize/2ys1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/face/recognize/2ys1.jpg -------------------------------------------------------------------------------- /workspace/face/recognize/2ys3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/face/recognize/2ys3.jpg -------------------------------------------------------------------------------- /workspace/face/recognize/2ys5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/face/recognize/2ys5.jpg -------------------------------------------------------------------------------- /workspace/inference/car.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/inference/car.jpg -------------------------------------------------------------------------------- /workspace/inference/gril.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/inference/gril.jpg -------------------------------------------------------------------------------- /workspace/inference/group.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/inference/group.jpg -------------------------------------------------------------------------------- /workspace/inference/yq.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/inference/yq.jpg -------------------------------------------------------------------------------- /workspace/inference/zand.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/inference/zand.jpg -------------------------------------------------------------------------------- /workspace/inference/zgjr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/inference/zgjr.jpg -------------------------------------------------------------------------------- /workspace/lesson1.py: -------------------------------------------------------------------------------- 1 | 2 | import torch 3 | import torch.nn as nn 4 | 5 | class Model(nn.Module): 6 | def __init__(self): 7 | super().__init__() 8 | 9 | self.conv = nn.Conv2d(1, 1, 3, stride=1, padding=1, bias=True) 10 | self.conv.weight.data.fill_(0.3) 11 | self.conv.bias.data.fill_(0.2) 12 | 13 | def forward(self, x): 14 | x = self.conv(x) 15 | # return x.view(int(x.size(0)), -1) 16 | return x.view(-1, int(x.numel() // x.size(0))) 17 | 18 | model = Model().eval() 19 | 20 | x = torch.full((1, 1, 3, 3), 1.0) 21 | y = model(x) 22 | print(y) 23 | 24 | torch.onnx.export( 25 | model, (x, ), "lesson1.onnx", verbose=True 26 | ) 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /workspace/makesure_input.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | def load_tensor(file): 4 | 5 | with open(file, "rb") as f: 6 | binary_data = f.read() 7 | 8 | magic_number, ndims, dtype = np.frombuffer(binary_data, np.uint32, count=3, offset=0) 9 | assert magic_number == 0xFCCFE2E2, f"{file} not a tensor file." 10 | 11 | dims = np.frombuffer(binary_data, np.uint32, count=ndims, offset=3 * 4) 12 | 13 | if dtype == 0: 14 | np_dtype = np.float32 15 | elif dtype == 1: 16 | np_dtype = np.float16 17 | else: 18 | assert False, f"Unsupport dtype = {dtype}, can not convert to numpy dtype" 19 | 20 | return np.frombuffer(binary_data, np_dtype, offset=(ndims + 3) * 4).reshape(*dims) 21 | 22 | 23 | tensor = load_tensor("demo.tensor") 24 | ts = [tensor[0, i*3:(i+1)*3].transpose(1, 2, 0) for i in range(4)] 25 | out = np.zeros((640, 640, 3)) 26 | out[::2, ::2, :] = ts[0] 27 | out[1::2, ::2, :] = ts[1] 28 | out[::2, 1::2, :] = ts[2] 29 | out[1::2, 1::2, :] = ts[3] 30 | print(out.shape) 31 | 32 | import cv2 33 | cv2.imwrite("demo.jpg", (out * 255).astype(np.uint8)) 34 | 35 | 36 | m = np.array([ 37 | [0.5, 0, -8], 38 | [0, 0.5, -2] 39 | ]) 40 | print(cv2.invertAffineTransform(m)) -------------------------------------------------------------------------------- /workspace/pose.show.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/pose.show.jpg -------------------------------------------------------------------------------- /workspace/street.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/street.jpg -------------------------------------------------------------------------------- /workspace/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/test.jpg -------------------------------------------------------------------------------- /workspace/unet.predict.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/unet.predict.jpg -------------------------------------------------------------------------------- /workspace/wget.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/wget.exe -------------------------------------------------------------------------------- /workspace/yq.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shouxieai/tensorRT_Pro/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/workspace/yq.jpg --------------------------------------------------------------------------------