背景:FPGA端程序需要确定的偏移地址,只能有一个指针。我们需要一次性的在DRAM上开辟内存空间然后传给IPcore来运算。所以我们必须从头编写MTCNN的代码。
目的:查出原MTCNN代码的内存空间的开辟量。
目录
一、旧MTCNN的内存实现
旧MTCNN的weight,input,output分别用malloc开辟新的内存空间。
1.1 每个子网络的构建
以Pnet为例
Pnet::Pnet(){
Pthreshold = 0.9;//0.6;
firstFlag = true;
//in order of [weight] [input] [output]
//the RGB image in pBox format
this->rgb = new pBox;
//conv1,prelu1
this->conv1_wb = new Weight;
this->conv1_out = new pBox;//output
this->conv1_out_pad = new pBox;//output padding
//pool1
this->pool1_conv1_wb = new Weight;
this->pool1_conv1_out = new pBox;//output
//conv2,relu2
this->conv2_wb = new Weight;
this->conv2_out = new pBox;//output
//conv3,relu3
this->conv3_wb = new Weight;
this->conv3_out = new pBox;//output
//post conv layers
this->conv4c1_wb = new Weight;
this->conv4c2_wb = new Weight;//weight
// this->score_matrix = new pBox;
this->score_ = new pBox;
// this->location_matrix = new pBox;
this->location_ = new pBox;
//weight pointer create,network initialize
// w oc ic ks s lp rp
long conv1 = initConvAndFc( this->conv1_wb, 10, 3, 3, 1, 0, 0);
long pool1_conv1=initConvAndFc(this->pool1_conv1_wb,16,10, 3, 2, 0, 0);
long conv2 = initConvAndFc( this->conv2_wb, 32, 16, 3, 1, 0, 0);
long conv3 = initConvAndFc( this->conv3_wb, 32, 32, 3, 1, 0, 0);
long conv4c1 = initConvAndFc(this->conv4c1_wb, 2, 32, 1, 1, 0, 0);
long conv4c2 = initConvAndFc(this->conv4c2_wb, 4, 32, 1, 1, 0, 0);
long dataNumber[12] = {conv1,10,pool1_conv1,16,conv2,32,conv3,32,conv4c1,2,conv4c2,4};
mydataFmt *pointTeam[12] = {this->conv1_wb->pdata, this->conv1_wb->pbias, \
this->pool1_conv1_wb->pdata, this->pool1_conv1_wb->pbias, \
this->conv2_wb->pdata, this->conv2_wb->pbias, \
this->conv3_wb->pdata, this->conv3_wb->pbias, \
this->conv4c1_wb->pdata, this->conv4c1_wb->pbias, \
this->conv4c2_wb->pdata, this->conv4c2_wb->pbias \
};
string filename = "Pnet.bin";
printf("Create Pnet,Read Pnet.bin ,12 pointers \n");
readData(filename, dataNumber, pointTeam, 12);
}
c++的类构造函数与析构函数 http://www.runoob.com/cplusplus/cpp-constructor-destructor.html
运用构造函数开辟每层的内存存入指针,每层存在一个结构体之中,用initConvandFc函数初始化weight的大小,用convolutioninit这些函数初始化feature的内存。
运用此方法构造的Pnet,Rnet,Onet
1.2 mtcnn的构造
因为Pnet根据金字塔结构,需要多次构造Pnet;
Rnet,Onet只需要构造一次。
子网络的构建mtcnn的类初始化函数之中实现。
1.3 权重的内存实现
网络初始化过程之中,初始化一系列权重指针,然后从文件读入权重。权重之间独立。
//weight pointer create,network initialize
// w oc ic ks s lp rp
long conv1 = initConvAndFc( this->conv1_wb, 10, 3, 3, 1, 0, 0);
long pool1_conv1=initConvAndFc(this->pool1_conv1_wb,16,10, 3, 2, 0, 0);
long conv2 = initConvAndFc( this->conv2_wb, 32, 16, 3, 1, 0, 0);
long conv3 = initConvAndFc( this->conv3_wb, 32, 32, 3, 1, 0, 0);
long conv4c1 = initConvAndFc(this->conv4c1_wb, 2, 32, 1, 1, 0, 0);
long conv4c2 = initConvAndFc(this->conv4c2_wb, 4, 32, 1, 1, 0, 0);
long dataNumber[12] = {conv1,10,pool1_conv1,16,conv2,32,conv3,32,conv4c1,2,conv4c2,4};
mydataFmt *pointTeam[12] = {this->conv1_wb->pdata, this->conv1_wb->pbias, \
this->pool1_conv1_wb->pdata, this->pool1_conv1_wb->pbias, \
this->conv2_wb->pdata, this->conv2_wb->pbias, \
this->conv3_wb->pdata, this->conv3_wb->pbias, \
this->conv4c1_wb->pdata, this->conv4c1_wb->pbias, \
this->conv4c2_wb->pdata, this->conv4c2_wb->pbias \
};
string filename = "Pnet.bin";
printf("Create Pnet,Read Pnet.bin ,12 pointers \n");
readData(filename, dataNumber, pointTeam, 12);
1.4 feature的内存实现
权重固定而featreu不固定,所以每次运行网络之前都会初始化feature。
if(firstFlag){
printf("Pnet buffer init\n");
//change Mat image to pBox format
image2MatrixInit(image, this->rgb);
//conv1,prelu1
convolutionInit(this->conv1_wb, this->rgb, this->conv1_out);
featurePadInit(this->conv1_out, this->conv1_out_pad, 0,1);
//pool1
convolutionInit(this->pool1_conv1_wb, this->conv1_out_pad, this->pool1_conv1_out);
//conv2,prelu2
convolutionInit(this->conv2_wb, this->pool1_conv1_out, this->conv2_out);
//conv3,prelu3
convolutionInit(this->conv3_wb, this->conv2_out, this->conv3_out);
//post conv layers
convolutionInit(this->conv4c1_wb, this->conv3_out, this->score_);
convolutionInit(this->conv4c2_wb, this->conv3_out, this->location_);
firstFlag = false;
}
以Pnet初始化为例,用相关的Init函数开辟独立的内存以供feature存储。
1.5 内存实现相关的子函数
void convolutionInit(const Weight *weightIn, const pBox *pboxParameter, pBox *outpBox){
outpBox->channel = weightIn->out_ChannelNum;
outpBox->width = (pboxParameter->width - weightIn->kernelSize) / weightIn->stride + 1;
outpBox->height = (pboxParameter->height - weightIn->kernelSize) / weightIn->stride + 1;
int outpBoxByteSize=weightIn->out_ChannelNum*outpBox->width*outpBox->height*sizeof(mydataFmt);
outpBox->pdata = (mydataFmt *)malloc(outpBoxByteSize);
if(outpBox->pdata==NULL)cout<<"the convolutionInit is failed!!"<<endl;
memset(outpBox->pdata , 0, outpBoxByteSize);
}
例如卷积的初始化函数就是独立的开辟出卷积需要的内存大小。
long initConvAndFc(struct Weight *weight, int schannel, int lchannel, int kersize, int stride, int leftPad,int rightPad){
weight->out_ChannelNum = schannel;
weight->in_ChannelNum = lchannel;
weight->kernelSize = kersize;
weight->stride = stride;
weight->leftPad = leftPad;
weight->rightPad = rightPad;
weight->pbias = (mydataFmt *)malloc(schannel*sizeof(mydataFmt));
if(weight->pbias==NULL)cout<<"In initConvAndFc weight buffer malloc failure!";
memset(weight->pbias, 0, schannel*sizeof(mydataFmt));
long byteLenght = weight->out_ChannelNum*weight->in_ChannelNum*weight->kernelSize*weight->kernelSize;
weight->pdata = (mydataFmt *)malloc(byteLenght*sizeof(mydataFmt));
if(weight->pdata==NULL)cout<<"In initConvAndFc weight buffer malloc failure!";
memset(weight->pdata, 0, byteLenght*sizeof(mydataFmt));
return byteLenght;
}
权重的初始化函数就是开辟出权重需要的大小。
二、新MTCNN内存实现的思路
按照weight,feature的顺序存储
其中,按照Pnet,Rnet,Onet的顺序存储。每个子网络之中按层的先后顺序来实现。
根据具体的卷积算出针对具体卷积的weight,input,output的偏移地址。
weight_offset=net_offset+weight_layer_offset
input_offset=feature_offset+feature_layer_offset
2.1 weight的初始化与权重写入
一次性开辟所有weight的内存,然后根据Pnet,Rnet,Onet的顺序写入
具体子网络之后用层用从前往后的层顺序。写入weight,
然后从weight文件中读入指针。
2.2 feature内存的初始化
Pnet
因为Pnet按照图像金字塔的结构,所以每层的feature大小都不一样。
按照pyramind的顺序,pyramid之中的feature按照层的顺序。
Rnet,Onet
按照层的顺序进行循环。一次性开辟内存空间反复使用。
三、IPcore的接口设计
- 接口传入该层参数,
- weight,input,output三个偏移量
- DRAM地址
//----------------convolution in FPGA-----------------------------------
void convolution_3x3(int inHight,int inWidth,int inChanNum,int outHight,int outWidth,int OutChanNum,int stride,
volatile float *SHARED_DRAM,
int weight_offset,int input_offset,int output offset){
#pragma HLS INTERFACE s_axilite register port=inHight bundle=axilite
#pragma HLS INTERFACE s_axilite register port=inWidth bundle=axilite
#pragma HLS INTERFACE s_axilite register port=inChanNum bundle=axilite
#pragma HLS INTERFACE s_axilite register port=outHight bundle=axilite
#pragma HLS INTERFACE s_axilite register port=outWidth bundle=axilite
#pragma HLS INTERFACE s_axilite register port=OutChanNum bundle=axilite
#pragma HLS INTERFACE s_axilite register port=stride bundle=axilite
#pragma HLS INTERFACE m_axi depth=DRAM_DEPTH port=SHARED_DRAM offset=slave bundle=memorybus
#pragma HLS INTERFACE s_axilite register port=weight_offset bundle=axilite
#pragma HLS INTERFACE s_axilite register port=input_offset bundle=axilite
#pragma HLS INTERFACE s_axilite register port=output offset bundle=axilite
四、weight的权重大小
网络尺寸表
Pnet
Feature size |
name | Kernel size |
Stride |
Padding |
12*12*3 |
conv1 ReLU1 |
3*3*10 |
1 |
Valid |
10*10*10 |
pool1_conv1 pool1_ReLU1 |
3*3*16 |
2 |
Same |
5*5*16 |
conv2 ReLU2 |
3*3*32 |
1 |
Valid |
3*3*32 |
conv3 ReLU3 |
3*3*32 |
1 |
Valid |
1*1*32 |
Rnet
Feature size |
name | Kernel size |
Stride |
Padding |
24*24*3 |
conv1 relu1 |
3*3*28 |
1 |
Same |
24*24*28 |
pool1_conv1 pool1_relu1 |
3*3*28 | 2 | Same |
12*12*28 | conv2 relu2 |
3*3*48 | 1 | Same |
12*12*48 | pool2_conv3 poo2_relu3 |
3*3*48 | 2 | Same |
6*6*48 | conv3 relu3 |
3*3*64 | 2 | Same |
3*3*64 |
Onet
Feature size |
name | Kernel size |
Stride |
Padding |
48*48*3 |
conv1 relu1 |
3*3*32 |
1 |
Same |
48*48*32 | conv2 relu2 |
3*3*32 | 2 |
Same |
24*24*32 |
conv3 relu3 |
3*3*64 | 1 |
Same |
24*24*64 |
conv4_ relu4_ |
3*3*64 | 2 |
Same |
12*12*64 |
conv5_ relu5_ |
3*3*128 | 2 |
Same |
6*6*128 |
conv6_ relu6_ |
3*3*128 | 2 |
Same |
3*3*128 |
4.1 Pnet weight的大小
----------Pnet conv1---------------------
-----------Init conv and Fc for weight---------------------
Current layer weight 1080 byte and bias 40 byte, total= 1120 byte
----------Pnet poo1_conv1---------------------
-----------Init conv and Fc for weight---------------------
Current layer weight 5760 byte and bias 64 byte, total= 5824 byte
----------Pnet conv2---------------------
-----------Init conv and Fc for weight---------------------
Current layer weight 18432 byte and bias 128 byte, total= 18560 byte
----------Pnet conv3---------------------
-----------Init conv and Fc for weight---------------------
Current layer weight 36864 byte and bias 128 byte, total= 36992 byte
----------Pnet conv4c1---------------------
-----------Init conv and Fc for weight---------------------
Current layer weight 256 byte and bias 8 byte, total= 264 byte
----------Pnet conv4c2---------------------
-----------Init conv and Fc for weight---------------------
Current layer weight 512 byte and bias 16 byte, total= 528 byte
Pnet
Pnet weight |
layer name | weight data byte | weight bias byte | total byte |
conv1 | 1080 | 40 | 1120 | |
pool1_conv1 | 5760 | 64 | 5824 | |
conv2 | 18432 | 128 | 18560 | |
conv3 | 36864 | 128 | 36992 | |
conv4c1 | 256 | 8 | 264 | |
conv4c2 | 512 | 16 | 528 |
Rnet
----------Rnet conv1---------------------
Current layer weight 3024 byte and bias 112 byte, total= 3136 byte
----------Rnet pool_conv1---------------------
Current layer weight 28224 byte and bias 112 byte, total= 28336 byte
----------Rnet conv2---------------------
Current layer weight 48384 byte and bias 192 byte, total= 48576 byte
----------Rnet pool2_conv3---------------------
Current layer weight 82944 byte and bias 192 byte, total= 83136 byte
----------Rnet conv3---------------------
Current layer weight 110592 byte and bias 256 byte, total= 110848 byte
----------Rnet fc4---------------------
Current layer weight 294912 byte and bias 512 byte, total= 295424 byte
----------Rnet score---------------------
Current layer weight 1024 byte and bias 8 byte, total= 1032 byte
----------Rnet location---------------------
Current layer weight 2048 byte and bias 16 byte, total= 2064 byte
Create Rnet,Read Rnet.bin ,16 pointers
Rnet weight |
layer name | weight data byte | weight bias byte | total byte |
conv1 | 3024 | 112 | 3136 | |
pool_conv1 | 28224 | 112 | 28336 | |
conv2 | 48384 | 192 | 48576 | |
pool2_conv3 | 82944 | 192 | 83136 | |
conv3 | 110592 | 256 | 110848 | |
fc4 | 294912 | 512 | 295424 | |
score | 1024 | 8 | 1032 | |
location | 2048 | 16 | 2064 |
Onet
----------Onet conv1---------------------
Current layer weight 3456 byte and bias 128 byte, total= 3584 byte
----------Onet conv2---------------------
Current layer weight 36864 byte and bias 128 byte, total= 36992 byte
----------Onet conv3---------------------
Current layer weight 73728 byte and bias 256 byte, total= 73984 byte
----------Onet conv4_---------------------
Current layer weight 147456 byte and bias 256 byte, total= 147712 byte
----------Onet conv5_---------------------
Current layer weight 294912 byte and bias 512 byte, total= 295424 byte
----------Onet conv6_---------------------
Current layer weight 589824 byte and bias 512 byte, total= 590336 byte
----------Onet fc5---------------------
Current layer weight 1179648 byte and bias 1024 byte, total= 1180672 byte
----------Onet score---------------------
Current layer weight 2048 byte and bias 8 byte, total= 2056 byte
----------Onet location---------------------
Current layer weight 4096 byte and bias 16 byte, total= 4112 byte
Create Onet,Read Onet.bin ,18 pointers
Onet buffer init
Onet weight |
layer name | weight data byte | weight bias byte | total byte |
conv1 | 3456 | 128 | 3584 | |
conv2 | 36864 | 128 | 36992 | |
conv3 | 73728 | 256 | 73984 | |
conv4_ | 147456 | 256 | 147712 | |
conv5_ | 294912 | 512 | 295424 | |
conv6_ | 589824 | 512 | 590336 | |
fc5 | 1179648 | 1024 | 1180672 | |
score | 2048 | 8 | 2056 | |
location | 4096 | 16 | 4112 |
五、feature的大小
5.1 Rnet
//input image to pBox format
RnetImage2MatrixInit(rgb);
featurePadInit(this->rgb, this->rgb_pad, 1, 1);
//conv1
convolutionInit(this->conv1_wb, this->rgb_pad, this->conv1_out);
featurePadInit(this->conv1_out, this->conv1_out_pad, 0, 1);
//pool1
convolutionInit(this->pool_conv1_wb, this->conv1_out_pad, this->pool_conv1_out);
featurePadInit(this->pool_conv1_out, this->pool_conv1_out_pad, 1, 1);
//conv2
convolutionInit(this->conv2_wb, this->pool_conv1_out_pad, this->conv2_out);
featurePadInit(this->conv2_out, this->conv2_out_pad, 0, 1);
//pool2
convolutionInit(this->pool2_conv3_wb, this->conv2_out_pad, this->pool2_conv3_out);
featurePadInit(this->pool2_conv3_out, this->pool2_conv3_out_pad, 0, 1);
//conv3
convolutionInit(this->conv3_wb, this->pool2_conv3_out_pad, this->conv3_out);
//post conv precess
fullconnectInit(this->fc4_wb, this->fc4_out);
fullconnectInit(this->score_wb, this->score_);
fullconnectInit(this->location_wb, this->location_);
据此生成的大小为:
Create Rnet,Read Rnet.bin ,16 pointers
Rnet weight buffer init SUCCESS!Start init feature buffer
-------Rnet image2Matrix buffer byte size 6912 -------
--------Feature pad buffer byte size 8112 -------
--------convolution buffer byte size 64512 -------
--------Feature pad buffer byte size 70000 -------
--------convolution buffer byte size 16128 -------
--------Feature pad buffer byte size 21952 -------
--------convolution buffer byte size 27648 -------
--------Feature pad buffer byte size 32448 -------
--------convolution buffer byte size 6912 -------
--------Feature pad buffer byte size 9408 -------
--------convolution buffer byte size 2304 -------
--------fullconnect buffer byte size 512 -------
--------fullconnect buffer byte size 8 -------
--------fullconnect buffer byte size 16 -------
Rnet feature |
feature name | bytesize |
rgb | 6912 | |
rgb_pad | 8112 | |
conv1_out | 64512 | |
conv1_out_pad | 70000 | |
pool_conv1_out | 16128 | |
pool_conv1_out_pad | 21952 | |
conv2_out | 27648 | |
conv2_out_pad | 32448 | |
pool2_conv3_out | 6912 | |
pool2_conv3_out_pad | 9408 | |
conv3_out | 2304 | |
fc4_out | 512 | |
score_ | 8 | |
location_ | 16 |
5.2 Onet
//Init the network
printf("Onet weight buffer init SUCCESS! Start init feature buffer \n");
//change image to pBox format
OnetImage2MatrixInit(rgb);
featurePadInit(this->rgb, this->rgb_pad, 1, 1);//s=1
//conv1
convolutionInit(this->conv1_wb, this->rgb_pad, this->conv1_out);
featurePadInit(this->conv1_out, this->conv1_out_pad, 0, 1);//s=2
//conv2
convolutionInit(this->conv2_wb, this->conv1_out_pad, this->conv2_out);
featurePadInit(this->conv2_out, this->conv2_out_pad, 1, 1);//s=1
//conv3
convolutionInit(this->conv3_wb, this->conv2_out_pad, this->conv3_out);
featurePadInit(this->conv3_out, this->conv3_out_pad, 0, 1);//s=2
//conv4_
convolutionInit(this->conv4_wb, this->conv3_out_pad, this->conv4_out);
featurePadInit(this->conv4_out, this->conv4_out_pad, 0, 1);//s=2
//conv5_
convolutionInit(this->conv5_wb, this->conv4_out_pad, this->conv5_out);
featurePadInit(this->conv5_out, this->conv5_out_pad, 0, 1);//s=2
//conv6_
convolutionInit(this->conv6_wb, this->conv5_out_pad, this->conv6_out);
//post conv precess
fullconnectInit(this->fc5_wb, this->fc5_out);
fullconnectInit(this->score_wb, this->score_);
fullconnectInit(this->location_wb, this->location_);
Onet feature |
feature name | bytesize |
rgb | 27648 | |
rgb_pad | 30000 | |
conv1_out | 294912 | |
conv1_out_pad | 307328 | |
conv2_out | 73728 | |
conv2_out_pad | 86528 | |
conv3_out | 147456 | |
conv3_out_pad | 160000 | |
conv4_out | 36864 | |
conv4_out_pad | 43264 | |
conv5_out | 18432 | |
conv5_out_pad | 25088 | |
conv6_out | 4608 | |
fc5_out | 1024 | |
score_ | 8 | |
location_ | 16 |
5.3 Pnet
Pnet的feature较多,有很多个pyramid,每个pyramid的尺寸都不一样。
//scales 0.400000 h:116 w:142
//scales 0.340000 h:98 w:120
//scales 0.289000 h:84 w:102
//scales 0.245650 h:72 w:88
//scales 0.208803 h:62 w:74
//scales 0.177482 h:52 w:64
//scales 0.150860 h:44 w:54
//scales 0.128231 h:38 w:46
//scales 0.108996 h:32 w:40
//scales 0.092647 h:28 w:34
//scales 0.078750 h:24 w:28
//scales 0.066937 h:20 w:24
//scales 0.056897 h:18 w:22
//scales 0.048362 h:14 w:18
Create Pnet,Read Pnet.bin ,12 pointers
------Start find Face function
scales 0.400000 h:116 w:142
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 197664 ----------------
--------convolution buffer byte size 638400 -------
--------Feature pad buffer byte size 648600 -------
--------convolution buffer byte size 255360 -------
--------convolution buffer byte size 478720 -------
--------convolution buffer byte size 447744 -------
--------convolution buffer byte size 27984 -------
--------convolution buffer byte size 55968 -------
scales 0.340000 h:98 w:120
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 141120 ----------------
--------convolution buffer byte size 453120 -------
--------Feature pad buffer byte size 461720 -------
--------convolution buffer byte size 181248 -------
--------convolution buffer byte size 335616 -------
--------convolution buffer byte size 309760 -------
--------convolution buffer byte size 19360 -------
--------convolution buffer byte size 38720 -------
scales 0.289000 h:84 w:102
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 102816 ----------------
--------convolution buffer byte size 328000 -------
--------Feature pad buffer byte size 335320 -------
--------convolution buffer byte size 131200 -------
--------convolution buffer byte size 239616 -------
--------convolution buffer byte size 217856 -------
--------convolution buffer byte size 13616 -------
--------convolution buffer byte size 27232 -------
scales 0.245650 h:72 w:88
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 76032 ----------------
--------convolution buffer byte size 240800 -------
--------Feature pad buffer byte size 247080 -------
--------convolution buffer byte size 96320 -------
--------convolution buffer byte size 173184 -------
--------convolution buffer byte size 154752 -------
--------convolution buffer byte size 9672 -------
--------convolution buffer byte size 19344 -------
scales 0.208803 h:62 w:74
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 55056 ----------------
--------convolution buffer byte size 172800 -------
--------Feature pad buffer byte size 178120 -------
--------convolution buffer byte size 69120 -------
--------convolution buffer byte size 121856 -------
--------convolution buffer byte size 106496 -------
--------convolution buffer byte size 6656 -------
--------convolution buffer byte size 13312 -------
scales 0.177482 h:52 w:64
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 39936 ----------------
--------convolution buffer byte size 124000 -------
--------Feature pad buffer byte size 128520 -------
--------convolution buffer byte size 49600 -------
--------convolution buffer byte size 85376 -------
--------convolution buffer byte size 72576 -------
--------convolution buffer byte size 4536 -------
--------convolution buffer byte size 9072 -------
scales 0.150860 h:44 w:54
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 28512 ----------------
--------convolution buffer byte size 87360 -------
--------Feature pad buffer byte size 91160 -------
--------convolution buffer byte size 34944 -------
--------convolution buffer byte size 58368 -------
--------convolution buffer byte size 47872 -------
--------convolution buffer byte size 2992 -------
--------convolution buffer byte size 5984 -------
scales 0.128231 h:38 w:46
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 20976 ----------------
--------convolution buffer byte size 63360 -------
--------Feature pad buffer byte size 66600 -------
--------convolution buffer byte size 25344 -------
--------convolution buffer byte size 40960 -------
--------convolution buffer byte size 32256 -------
--------convolution buffer byte size 2016 -------
--------convolution buffer byte size 4032 -------
scales 0.108996 h:32 w:40
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 15360 ----------------
--------convolution buffer byte size 45600 -------
--------Feature pad buffer byte size 48360 -------
--------convolution buffer byte size 18240 -------
--------convolution buffer byte size 28288 -------
--------convolution buffer byte size 21120 -------
--------convolution buffer byte size 1320 -------
--------convolution buffer byte size 2640 -------
scales 0.092647 h:28 w:34
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 11424 ----------------
--------convolution buffer byte size 33280 -------
--------Feature pad buffer byte size 35640 -------
--------convolution buffer byte size 13312 -------
--------convolution buffer byte size 19712 -------
--------convolution buffer byte size 13824 -------
--------convolution buffer byte size 864 -------
--------convolution buffer byte size 1728 -------
scales 0.078750 h:24 w:28
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 8064 ----------------
--------convolution buffer byte size 22880 -------
--------Feature pad buffer byte size 24840 -------
--------convolution buffer byte size 9152 -------
--------convolution buffer byte size 12672 -------
--------convolution buffer byte size 8064 -------
--------convolution buffer byte size 504 -------
--------convolution buffer byte size 1008 -------
scales 0.066937 h:20 w:24
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 5760 ----------------
--------convolution buffer byte size 15840 -------
--------Feature pad buffer byte size 17480 -------
--------convolution buffer byte size 6336 -------
--------convolution buffer byte size 8064 -------
--------convolution buffer byte size 4480 -------
--------convolution buffer byte size 280 -------
--------convolution buffer byte size 560 -------
scales 0.056897 h:18 w:22
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 4752 ----------------
--------convolution buffer byte size 12800 -------
--------Feature pad buffer byte size 14280 -------
--------convolution buffer byte size 5120 -------
--------convolution buffer byte size 6144 -------
--------convolution buffer byte size 3072 -------
--------convolution buffer byte size 192 -------
--------convolution buffer byte size 384 -------
scales 0.048362 h:14 w:18
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 3024 ----------------
--------convolution buffer byte size 7680 -------
--------Feature pad buffer byte size 8840 -------
--------convolution buffer byte size 3072 -------
--------convolution buffer byte size 3072 -------
--------convolution buffer byte size 1024 -------
--------convolution buffer byte size 64 -------
--------convolution buffer byte size 128 -------
六、网络的总尺寸
6.1 权重尺寸
Pnet weight |
layer name | weight data byte | weight bias byte | total byte |
conv1 | 1080 | 40 | 1120 | |
pool1_conv1 | 5760 | 64 | 5824 | |
conv2 | 18432 | 128 | 18560 | |
conv3 | 36864 | 128 | 36992 | |
conv4c1 | 256 | 8 | 264 | |
conv4c2 | 512 | 16 | 528 |
Rnet weight |
layer name | weight data byte | weight bias byte | total byte |
conv1 | 3024 | 112 | 3136 | |
pool_conv1 | 28224 | 112 | 28336 | |
conv2 | 48384 | 192 | 48576 | |
pool2_conv3 | 82944 | 192 | 83136 | |
conv3 | 110592 | 256 | 110848 | |
fc4 | 294912 | 512 | 295424 | |
score | 1024 | 8 | 1032 | |
location | 2048 | 16 | 2064 |
Onet weight |
layer name | weight data byte | weight bias byte | total byte |
conv1 | 3456 | 128 | 3584 | |
conv2 | 36864 | 128 | 36992 | |
conv3 | 73728 | 256 | 73984 | |
conv4_ | 147456 | 256 | 147712 | |
conv5_ | 294912 | 512 | 295424 | |
conv6_ | 589824 | 512 | 590336 | |
fc5 | 1179648 | 1024 | 1180672 | |
score | 2048 | 8 | 2056 | |
location | 4096 | 16 | 4112 |
6.2 feature大小
Rnet feature |
feature name | bytesize |
rgb | 6912 | |
rgb_pad | 8112 | |
conv1_out | 64512 | |
conv1_out_pad | 70000 | |
pool_conv1_out | 16128 | |
pool_conv1_out_pad | 21952 | |
conv2_out | 27648 | |
conv2_out_pad | 32448 | |
pool2_conv3_out | 6912 | |
pool2_conv3_out_pad | 9408 | |
conv3_out | 2304 | |
fc4_out | 512 | |
score_ | 8 | |
location_ | 16 |
Onet feature |
feature name | bytesize |
rgb | 27648 | |
rgb_pad | 30000 | |
conv1_out | 294912 | |
conv1_out_pad | 307328 | |
conv2_out | 73728 | |
conv2_out_pad | 86528 | |
conv3_out | 147456 | |
conv3_out_pad | 160000 | |
conv4_out | 36864 | |
conv4_out_pad | 43264 | |
conv5_out | 18432 | |
conv5_out_pad | 25088 | |
conv6_out | 4608 | |
fc5_out | 1024 | |
score_ | 8 | |
location_ | 16 |
//scales 0.400000 h:116 w:142
//scales 0.340000 h:98 w:120
//scales 0.289000 h:84 w:102
//scales 0.245650 h:72 w:88
//scales 0.208803 h:62 w:74
//scales 0.177482 h:52 w:64
//scales 0.150860 h:44 w:54
//scales 0.128231 h:38 w:46
//scales 0.108996 h:32 w:40
//scales 0.092647 h:28 w:34
//scales 0.078750 h:24 w:28
//scales 0.066937 h:20 w:24
//scales 0.056897 h:18 w:22
//scales 0.048362 h:14 w:18
Create Pnet,Read Pnet.bin ,12 pointers
------Start find Face function
scales 0.400000 h:116 w:142
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 197664 ----------------
--------convolution buffer byte size 638400 -------
--------Feature pad buffer byte size 648600 -------
--------convolution buffer byte size 255360 -------
--------convolution buffer byte size 478720 -------
--------convolution buffer byte size 447744 -------
--------convolution buffer byte size 27984 -------
--------convolution buffer byte size 55968 -------
scales 0.340000 h:98 w:120
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 141120 ----------------
--------convolution buffer byte size 453120 -------
--------Feature pad buffer byte size 461720 -------
--------convolution buffer byte size 181248 -------
--------convolution buffer byte size 335616 -------
--------convolution buffer byte size 309760 -------
--------convolution buffer byte size 19360 -------
--------convolution buffer byte size 38720 -------
scales 0.289000 h:84 w:102
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 102816 ----------------
--------convolution buffer byte size 328000 -------
--------Feature pad buffer byte size 335320 -------
--------convolution buffer byte size 131200 -------
--------convolution buffer byte size 239616 -------
--------convolution buffer byte size 217856 -------
--------convolution buffer byte size 13616 -------
--------convolution buffer byte size 27232 -------
scales 0.245650 h:72 w:88
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 76032 ----------------
--------convolution buffer byte size 240800 -------
--------Feature pad buffer byte size 247080 -------
--------convolution buffer byte size 96320 -------
--------convolution buffer byte size 173184 -------
--------convolution buffer byte size 154752 -------
--------convolution buffer byte size 9672 -------
--------convolution buffer byte size 19344 -------
scales 0.208803 h:62 w:74
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 55056 ----------------
--------convolution buffer byte size 172800 -------
--------Feature pad buffer byte size 178120 -------
--------convolution buffer byte size 69120 -------
--------convolution buffer byte size 121856 -------
--------convolution buffer byte size 106496 -------
--------convolution buffer byte size 6656 -------
--------convolution buffer byte size 13312 -------
scales 0.177482 h:52 w:64
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 39936 ----------------
--------convolution buffer byte size 124000 -------
--------Feature pad buffer byte size 128520 -------
--------convolution buffer byte size 49600 -------
--------convolution buffer byte size 85376 -------
--------convolution buffer byte size 72576 -------
--------convolution buffer byte size 4536 -------
--------convolution buffer byte size 9072 -------
scales 0.150860 h:44 w:54
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 28512 ----------------
--------convolution buffer byte size 87360 -------
--------Feature pad buffer byte size 91160 -------
--------convolution buffer byte size 34944 -------
--------convolution buffer byte size 58368 -------
--------convolution buffer byte size 47872 -------
--------convolution buffer byte size 2992 -------
--------convolution buffer byte size 5984 -------
scales 0.128231 h:38 w:46
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 20976 ----------------
--------convolution buffer byte size 63360 -------
--------Feature pad buffer byte size 66600 -------
--------convolution buffer byte size 25344 -------
--------convolution buffer byte size 40960 -------
--------convolution buffer byte size 32256 -------
--------convolution buffer byte size 2016 -------
--------convolution buffer byte size 4032 -------
scales 0.108996 h:32 w:40
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 15360 ----------------
--------convolution buffer byte size 45600 -------
--------Feature pad buffer byte size 48360 -------
--------convolution buffer byte size 18240 -------
--------convolution buffer byte size 28288 -------
--------convolution buffer byte size 21120 -------
--------convolution buffer byte size 1320 -------
--------convolution buffer byte size 2640 -------
scales 0.092647 h:28 w:34
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 11424 ----------------
--------convolution buffer byte size 33280 -------
--------Feature pad buffer byte size 35640 -------
--------convolution buffer byte size 13312 -------
--------convolution buffer byte size 19712 -------
--------convolution buffer byte size 13824 -------
--------convolution buffer byte size 864 -------
--------convolution buffer byte size 1728 -------
scales 0.078750 h:24 w:28
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 8064 ----------------
--------convolution buffer byte size 22880 -------
--------Feature pad buffer byte size 24840 -------
--------convolution buffer byte size 9152 -------
--------convolution buffer byte size 12672 -------
--------convolution buffer byte size 8064 -------
--------convolution buffer byte size 504 -------
--------convolution buffer byte size 1008 -------
scales 0.066937 h:20 w:24
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 5760 ----------------
--------convolution buffer byte size 15840 -------
--------Feature pad buffer byte size 17480 -------
--------convolution buffer byte size 6336 -------
--------convolution buffer byte size 8064 -------
--------convolution buffer byte size 4480 -------
--------convolution buffer byte size 280 -------
--------convolution buffer byte size 560 -------
scales 0.056897 h:18 w:22
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 4752 ----------------
--------convolution buffer byte size 12800 -------
--------Feature pad buffer byte size 14280 -------
--------convolution buffer byte size 5120 -------
--------convolution buffer byte size 6144 -------
--------convolution buffer byte size 3072 -------
--------convolution buffer byte size 192 -------
--------convolution buffer byte size 384 -------
scales 0.048362 h:14 w:18
Start run Pnet
Pnet feature buffer init
----------image to matrix buffer byte size 3024 ----------------
--------convolution buffer byte size 7680 -------
--------Feature pad buffer byte size 8840 -------
--------convolution buffer byte size 3072 -------
--------convolution buffer byte size 3072 -------
--------convolution buffer byte size 1024 -------
--------convolution buffer byte size 64 -------
--------convolution buffer byte size 128 -------