Change CenterNet input dimension.

This commit changes the image input dimension, it updates the
CenterNet detection class.

Signed-off-by: Davide Sapienza <sapienza.dav@gmail.com>
This commit is contained in:
Davide Sapienza
2020-02-06 18:08:06 +01:00
parent 507d30bf52
commit 516c1e6636
5 changed files with 22 additions and 14 deletions
+3 -3
View File
@@ -73,14 +73,14 @@ class CenternetDetection {
//processing
float toll = 0.000001;
int K = 100;
int width = 56; // TODO
int width = 128;//56; // TODO
public:
dnnType *rt_out[4];
float inp_height = 224;//512;
float inp_width = 224;//512;
float inp_height = 512;//224;//512;
float inp_width = 512;//224;//512;
int classes = 80;
int num = 0;
+11 -6
View File
@@ -18,7 +18,7 @@ bool CenternetDetection::init(std::string tensor_path) {
std::cout<<(tensor_path).c_str()<<"\n";
netRT = new tk::dnn::NetworkRT(NULL, (tensor_path).c_str() );
dim = tk::dnn::dataDim_t(1, 3, 224, 224, 1);
dim = tk::dnn::dataDim_t(1, 3, 512, 512, 1);
const char *coco_class_name_[] = {
"person", "bicycle", "car", "motorcycle", "airplane",
"bus", "train", "truck", "boat", "traffic light", "fire hydrant",
@@ -43,9 +43,12 @@ bool CenternetDetection::init(std::string tensor_path) {
checkCuda(cudaMallocHost(&input, sizeof(dnnType)*netRT->input_dim.tot()));
checkCuda(cudaMalloc(&input_d, sizeof(dnnType)*netRT->input_dim.tot()));
dim_hm = tk::dnn::dataDim_t(1, 80, 56, 56, 1);
dim_wh = tk::dnn::dataDim_t(1, 2, 56, 56, 1);
dim_reg = tk::dnn::dataDim_t(1, 2, 56, 56, 1);
// dim_hm = tk::dnn::dataDim_t(1, 80, 56, 56, 1);
// dim_wh = tk::dnn::dataDim_t(1, 2, 56, 56, 1);
// dim_reg = tk::dnn::dataDim_t(1, 2, 56, 56, 1);
dim_hm = tk::dnn::dataDim_t(1, 80, 128, 128, 1);
dim_wh = tk::dnn::dataDim_t(1, 2, 128, 128, 1);
dim_reg = tk::dnn::dataDim_t(1, 2, 128, 128, 1);
checkCuda( cudaMalloc(&topk_scores, dim_hm.c * K *sizeof(float)) );
checkCuda( cudaMalloc(&topk_inds_, dim_hm.c * K *sizeof(int)) );
@@ -93,6 +96,8 @@ bool CenternetDetection::init(std::string tensor_path) {
mean << 0.408, 0.447, 0.47;
stddev << 0.289, 0.274, 0.278;
// mean << 0.485, 0.456, 0.406;
// stddev << 0.229, 0.224, 0.225;
}
void CenternetDetection::testdog() {
@@ -104,8 +109,8 @@ void CenternetDetection::testdog() {
imageORIG.convertTo(imageF, CV_32FC3, 1/255.0);
sz = imageF.size();
std::cout<<"image: "<<sz.width<<", "<<sz.height<<std::endl;
resize(imageF, imageF, cv::Size(256, 256));
const int cropSize = 224;
resize(imageF, imageF, cv::Size(512, 512));
const int cropSize = 512;
const int offsetW = (imageF.cols - cropSize) / 2;
const int offsetH = (imageF.rows - cropSize) / 2;
const cv::Rect roi(offsetW, offsetH, cropSize, cropSize);
+6 -3
View File
@@ -31,16 +31,19 @@ void DeformConv2d::initCUDNN() {
// kernel ones
checkCuda( cudaMalloc(&ones_d1, (height_ones*width_ones)*sizeof(dnnType)) );
float aus1[height_ones*width_ones];
dnnType *aus1;
checkCuda( cudaMallocHost(&aus1, (height_ones*width_ones)*sizeof(dnnType)) );
for(int i=0; i<height_ones*width_ones; i++)
aus1[i]=1.0f;
checkCuda( cudaMemcpy(ones_d1, aus1, (height_ones*width_ones)*sizeof(dnnType), cudaMemcpyHostToDevice) );
checkCuda( cudaFreeHost(aus1) );
checkCuda( cudaMalloc(&ones_d2, dim_ones*sizeof(dnnType)) );
float aus2[dim_ones];
dnnType *aus2;
checkCuda( cudaMallocHost(&aus2, dim_ones*sizeof(dnnType)) );
for(int i=0; i<dim_ones; i++)
aus2[i]=1.0f;
checkCuda( cudaMemcpy(ones_d2, aus2, (dim_ones)*sizeof(dnnType), cudaMemcpyHostToDevice) );
checkCuda( cudaFreeHost(aus2) );
checkCuda( cudaDeviceSynchronize() );
}
+1 -1
View File
@@ -104,7 +104,7 @@ int main()
{
// Network layout
tk::dnn::dataDim_t dim(1, 3, 224, 224, 1);
tk::dnn::dataDim_t dim(1, 3, 512, 512, 1);
tk::dnn::Network net(dim);
tk::dnn::Layer *last1, *last2, *last3, *last4;
tk::dnn::Layer *base1, *base2, *base3, *base4, *base5, *base6, *ida1, *ida2_1, *ida2_2, *ida3_1, *ida3_2, *ida3_3, *idaup_1, *idaup_2;
+1 -1
View File
@@ -187,7 +187,7 @@ int main()
{
// Network layout
tk::dnn::dataDim_t dim(1, 3, 224, 224, 1);
tk::dnn::dataDim_t dim(1, 3, 512, 512, 1);
tk::dnn::Network net(dim);
tk::dnn::Conv2d conv1(&net, 64, 7, 7, 2, 2, 3, 3, conv1_bin, true);