/yolo-tensorrt

darknet -> tensorrt. TensorRT7 yolov3 yolov4 use raw darknet *.weights and *.cfg fils. If the wrapper is useful to you,please Star it.

Primary LanguageC++

!!! news:support yolov4 ,yolov4-tiny and Tensorrt7_

INTRODUCTION

The project is the encapsulation of nvidia official yolo-tensorrt implementation. And you must have the trained yolo model(.weights) and .cfg file from the darknet.

PLATFORM

model gpu precision memory used detect time
yolov3-416x416 gtx1050 INT8 25ms
yolov3-416x416 gtx1050 FLOAT32 50ms
yolov3-608x608 gtx1050 INT8 ~450M ~50ms
yolov3-608x608 gtx1050 FLOAT32 ~1000M ~95ms
yolov3-416x416 jetson nano (15w) HALF(FP16) 250ms

WRAPPER

Prepare the pretrained .weights and .cfg model.

Detector detector;
Config config;
cv::Mat mat_image = cv::imread("dog.jpg");

std::vector<Result> res;
detector.detect(mat_image, res)

How to use yolo-trt as DLL or SO libraries

windows10

  • dependency : TensorRT 7.1.3.4 , cuda 11.0 , cudnn 8.0 , opencv3.3 , gflags , vs2015

  • build:

    open MSVC sln/sln.sln file

    • dll project : the trt yolo detector dll
    • demo project : test of the dll

ubuntu

sudo apt-get install libgflags-dev
cd yolo-tensorrt/
mkdir build
cd build/
cmake ..
make

The project generate the libdetector.so lib, and the sample code. If you want to use the generated libdetector.so lib in your own project,the cmake file perhaps could help you in scripts dir.

  • jetson nano

    dependency : gflags , JetPack 4.2.2

    note: when the platform is jetson nano the gencode arch must be set compute_53,code=sm_53 at cmake file.

  • jetson xavier nx

    dependency : gflags , JetPack 4.4

    note: when the platform is jetson-xavier-nx the gencode arch must be set compute_72,code=sm_72 at cmake file.

API

struct Config
{
	std::string file_model_cfg = "configs/yolov3.cfg";

	std::string file_model_weights = "configs/yolov3.weights";

	float detect_thresh = 0.9;

	ModelType net_type = YOLOV3;

	Precision inference_precison = INT8;
	
	int gpu_id = 0;

	std::string calibration_image_list_file_txt = "configs/calibration_images.txt";
};

class API Detector
{
public:
	explicit Detector();
	~Detector();

	void init(const Config &config);

	void detect(const cv::Mat &mat_image, std::vector<Result> &vec_result);

private:
	Detector(const Detector &);
	const Detector &operator =(const Detector &);
	class Impl;
	Impl *_impl;
};

REFERENCE