Mnist works at the moment with trt8,others like yolo4tiny and mobilenet generate the engine files but crash after throwing nvifer1::CudaRuntimeError and when demo is being run ,it doesnt deserialize properly and crashes

This commit is contained in:
perseusdg
2021-08-29 03:18:58 +05:30
parent 3d8b1ac494
commit 2ffe07057e
12 changed files with 255 additions and 42 deletions
+3
View File
@@ -47,5 +47,8 @@ namespace tk { namespace dnn {
std::vector<tk::dnn::Layer*> &netLayers, const std::vector<std::string>& names);
std::vector<std::string> darknetReadNames(const std::string& names_file);
tk::dnn::Network* darknetParser(const std::string& cfg_file, const std::string& wgs_path, const std::string& names_file);
void loadYoloInfo(const std::string &cfg_file,int lineNo,std::vector<float> &mask,std::vector<float> &anchors,int &num,int &classes,float &nms_thresh,int &nms_kind,int &coords);
void loadYoloInitInfo(int &channels,int &width,int &height,const std::string &cfg_file);
std::vector<int> noYolosLine(const std::string &cfg_file);
}}
+1 -1
View File
@@ -87,7 +87,7 @@ class DetectionNN {
* @param n_batches maximum number of batches to use in inference
* @return true if everything is correct, false otherwise.
*/
virtual bool init(const std::string& tensor_path, const int n_classes=80, const int n_batches=1, const float conf_thresh=0.3) = 0;
virtual bool init(const std::string& tensor_path,const std::string& cfg_path,const std::string& name_path, const int n_classes=80, const int n_batches=1, const float conf_thresh=0.3) = 0;
/**
* This method performs the whole detection of the NN.
+1 -1
View File
@@ -7,6 +7,7 @@
#include "Layer.h"
#include "NvInfer.h"
#include <memory>
#include <tkDNN/kernels.h>
namespace tk { namespace dnn {
@@ -52,7 +53,6 @@ public:
class NetworkRT {
public:
+4 -3
View File
@@ -4,9 +4,9 @@
#include "opencv2/opencv.hpp"
#include "DetectionNN.h"
#include "DarknetParser.h"
namespace tk { namespace dnn {
namespace tk { namespace dnn {
class Yolo3Detection : public DetectionNN
{
private:
@@ -19,12 +19,13 @@ private:
tk::dnn::Yolo* getYoloLayer(int n=0);
cv::Mat bgr_h;
std::vector<int> noYolos;
public:
Yolo3Detection() {};
~Yolo3Detection() {};
bool init(const std::string& tensor_path, const int n_classes=80, const int n_batches=1, const float conf_thresh=0.3);
bool init(const std::string& tensor_path,const std::string& cfg_path,const std::string& name_path,const int n_classes=80, const int n_batches=1, const float conf_thresh=0.3);
void preprocess(cv::Mat &frame, const int bi=0);
void postprocess(const int bi=0,const bool mAP=false);
};
+1 -1
View File
@@ -41,7 +41,7 @@ public:
virtual int enqueue(int batchSize, const void*const * inputs, void* const* outputs, void* workspace, cudaStream_t stream) NOEXCEPT override {
reorgForward((dnnType*)reinterpret_cast<const dnnType*>(inputs[0]),
reorgForward((dnnType*)reinterpret_cast<const dnnType*>(inputs[0]),
reinterpret_cast<dnnType*>(outputs[0]),
batchSize, c, h, w, stride, stream);
return 0;
+1
View File
@@ -31,6 +31,7 @@ public:
classes = readBUF<int>(buf);
num = readBUF<int>(buf);
n_masks = readBUF<int>(buf);
std::cout<<n_masks<<std::endl;
scaleXY = readBUF<float>(buf);
nms_thresh = readBUF<float>(buf);
nms_kind = readBUF<int>(buf);