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:
@@ -73,14 +73,14 @@ class CenternetDetection {
|
|||||||
//processing
|
//processing
|
||||||
float toll = 0.000001;
|
float toll = 0.000001;
|
||||||
int K = 100;
|
int K = 100;
|
||||||
int width = 56; // TODO
|
int width = 128;//56; // TODO
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
dnnType *rt_out[4];
|
dnnType *rt_out[4];
|
||||||
|
|
||||||
float inp_height = 224;//512;
|
float inp_height = 512;//224;//512;
|
||||||
float inp_width = 224;//512;
|
float inp_width = 512;//224;//512;
|
||||||
|
|
||||||
int classes = 80;
|
int classes = 80;
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ bool CenternetDetection::init(std::string tensor_path) {
|
|||||||
std::cout<<(tensor_path).c_str()<<"\n";
|
std::cout<<(tensor_path).c_str()<<"\n";
|
||||||
netRT = new tk::dnn::NetworkRT(NULL, (tensor_path).c_str() );
|
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_[] = {
|
const char *coco_class_name_[] = {
|
||||||
"person", "bicycle", "car", "motorcycle", "airplane",
|
"person", "bicycle", "car", "motorcycle", "airplane",
|
||||||
"bus", "train", "truck", "boat", "traffic light", "fire hydrant",
|
"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(cudaMallocHost(&input, sizeof(dnnType)*netRT->input_dim.tot()));
|
||||||
checkCuda(cudaMalloc(&input_d, 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_hm = tk::dnn::dataDim_t(1, 80, 56, 56, 1);
|
||||||
dim_wh = tk::dnn::dataDim_t(1, 2, 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_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_scores, dim_hm.c * K *sizeof(float)) );
|
||||||
checkCuda( cudaMalloc(&topk_inds_, dim_hm.c * K *sizeof(int)) );
|
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;
|
mean << 0.408, 0.447, 0.47;
|
||||||
stddev << 0.289, 0.274, 0.278;
|
stddev << 0.289, 0.274, 0.278;
|
||||||
|
// mean << 0.485, 0.456, 0.406;
|
||||||
|
// stddev << 0.229, 0.224, 0.225;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CenternetDetection::testdog() {
|
void CenternetDetection::testdog() {
|
||||||
@@ -104,8 +109,8 @@ void CenternetDetection::testdog() {
|
|||||||
imageORIG.convertTo(imageF, CV_32FC3, 1/255.0);
|
imageORIG.convertTo(imageF, CV_32FC3, 1/255.0);
|
||||||
sz = imageF.size();
|
sz = imageF.size();
|
||||||
std::cout<<"image: "<<sz.width<<", "<<sz.height<<std::endl;
|
std::cout<<"image: "<<sz.width<<", "<<sz.height<<std::endl;
|
||||||
resize(imageF, imageF, cv::Size(256, 256));
|
resize(imageF, imageF, cv::Size(512, 512));
|
||||||
const int cropSize = 224;
|
const int cropSize = 512;
|
||||||
const int offsetW = (imageF.cols - cropSize) / 2;
|
const int offsetW = (imageF.cols - cropSize) / 2;
|
||||||
const int offsetH = (imageF.rows - cropSize) / 2;
|
const int offsetH = (imageF.rows - cropSize) / 2;
|
||||||
const cv::Rect roi(offsetW, offsetH, cropSize, cropSize);
|
const cv::Rect roi(offsetW, offsetH, cropSize, cropSize);
|
||||||
|
|||||||
@@ -31,16 +31,19 @@ void DeformConv2d::initCUDNN() {
|
|||||||
// kernel ones
|
// kernel ones
|
||||||
|
|
||||||
checkCuda( cudaMalloc(&ones_d1, (height_ones*width_ones)*sizeof(dnnType)) );
|
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++)
|
for(int i=0; i<height_ones*width_ones; i++)
|
||||||
aus1[i]=1.0f;
|
aus1[i]=1.0f;
|
||||||
checkCuda( cudaMemcpy(ones_d1, aus1, (height_ones*width_ones)*sizeof(dnnType), cudaMemcpyHostToDevice) );
|
checkCuda( cudaMemcpy(ones_d1, aus1, (height_ones*width_ones)*sizeof(dnnType), cudaMemcpyHostToDevice) );
|
||||||
|
checkCuda( cudaFreeHost(aus1) );
|
||||||
checkCuda( cudaMalloc(&ones_d2, dim_ones*sizeof(dnnType)) );
|
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++)
|
for(int i=0; i<dim_ones; i++)
|
||||||
aus2[i]=1.0f;
|
aus2[i]=1.0f;
|
||||||
checkCuda( cudaMemcpy(ones_d2, aus2, (dim_ones)*sizeof(dnnType), cudaMemcpyHostToDevice) );
|
checkCuda( cudaMemcpy(ones_d2, aus2, (dim_ones)*sizeof(dnnType), cudaMemcpyHostToDevice) );
|
||||||
|
checkCuda( cudaFreeHost(aus2) );
|
||||||
checkCuda( cudaDeviceSynchronize() );
|
checkCuda( cudaDeviceSynchronize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ int main()
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Network layout
|
// 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::Network net(dim);
|
||||||
tk::dnn::Layer *last1, *last2, *last3, *last4;
|
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;
|
tk::dnn::Layer *base1, *base2, *base3, *base4, *base5, *base6, *ida1, *ida2_1, *ida2_2, *ida3_1, *ida3_2, *ida3_3, *idaup_1, *idaup_2;
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ int main()
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Network layout
|
// 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::Network net(dim);
|
||||||
|
|
||||||
tk::dnn::Conv2d conv1(&net, 64, 7, 7, 2, 2, 3, 3, conv1_bin, true);
|
tk::dnn::Conv2d conv1(&net, 64, 7, 7, 2, 2, 3, 3, conv1_bin, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user