Merge branch 'cnet' of https://github.com/ceccocats/tkDNN into cnet

This commit is contained in:
xavier
2020-02-21 10:49:35 +01:00
4 changed files with 152 additions and 170 deletions
+18 -1
View File
@@ -6,14 +6,31 @@
#include <thrust/gather.h>
#include <thrust/copy.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "opencv2/opencv.hpp"
#include "tkdnn.h"
struct threshold : public thrust::binary_function<float,float,float>
{
__host__ __device__
float operator()(float x, float y) {
double toll = 1e-6;
if(fabsf(x-y)>toll)
return 0.0f;
else
return x;
}
};
void sort(dnnType *src_begin, dnnType *src_end, int *idsrc);
void topk(dnnType *src_begin, int *idsrc, int K, float *topk_scores,
int *topk_inds, float *topk_ys, float *topk_xs);
void sortAndTopKonDevice(dnnType *src_begin, int *idsrc, float *topk_scores, int *topk_inds, float *topk_ys, float *topk_xs, const int size, const int K, const int n_classes);
void subtractWithThreshold(dnnType *src_begin, dnnType *src_end, dnnType *src2_begin, dnnType *src_out);
void normalize(float *bgr, const int ch, const int h, const int w, const float *mean, const float *stddev);
void subtractWithThreshold(dnnType *src_begin, dnnType *src_end, dnnType *src2_begin, dnnType *src_out, struct threshold op);
void topKxyclasses(int *ids_begin, int *ids_end, const int K, const int size, const int wh, int *clses, int *xs, int *ys);
void topKxyAddOffset(int * ids_begin, const int K, const int size, int *intxs_begin, int *intys_begin,
float *xs_begin, float *ys_begin, dnnType *src_begin, float *src_out, int *ids_out);
+16 -7
View File
@@ -15,6 +15,7 @@
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "opencv2/opencv.hpp"
#include "tkdnn.h"
#include "sorting.h"
@@ -29,20 +30,24 @@ class CenternetDetection {
private:
tk::dnn::NetworkRT *netRT = nullptr;
dnnType *input_h, *input, *input_d;
dnnType *input_d;
int ndets = 0;
// tk::dnn::Yolo::detection *dets = nullptr;
cv::Mat imageF;
cv::Mat bgr[3];
cv::cuda::GpuMat imageF1_d, imageF2_d;
cv::cuda::GpuMat bgr[3];
// std::vector< cv::cuda::GpuMat > bgr;
// variable to test cnet on dog pictures
tk::dnn::dataDim_t dim;
tk::dnn::dataDim_t dim2;
cv::Size sz;
cv::Size sz, sz_old;
const char *input_bin = "../tests/resnet101_cnet/debug/input.bin";
cv::cuda::Stream stream;
struct threshold op;
// pre-process
tk::dnn::dataDim_t dim_hm;
tk::dnn::dataDim_t dim_wh;
@@ -66,10 +71,15 @@ class CenternetDetection {
float *target_coords;
cv::Vec<float, 3> mean;
cv::Vec<float, 3> stddev;
float *mean_d;
float *stddev_d;
float *d_ptrs;
cv::Mat src;
cv::Mat dst;
cv::Mat dst;
cv::Mat dst2;
cv::Mat trans, trans2;
//processing
float toll = 0.000001;
int K = 100;
@@ -108,7 +118,6 @@ class CenternetDetection {
* @return Success of the initialization
*/
bool init(std::string tensor_path);
void testdog();
cv::Mat draw(cv::Mat &frame);
void update(cv::Mat &frame);