python - How to create an caffemodel file from training image and its labeled? -


i working in age classification based on opensource @ here python code has

age_net_pretrained='./age_net.caffemodel' age_net_model_file='./deploy_age.prototxt' age_net = caffe.classifier(age_net_model_file, age_net_pretrained,        channel_swap=(2,1,0),        raw_scale=255,        image_dims=(256, 256)) 

in .prototxt file shown below. remain 1 file ".caffemodel". source code, provided before. however, create again based on face database. have tutorial or way create it? assume have folder image include 100 images , divided belongs each age groups (1 1) such as

image1.png 1 image2.png 1 .. image10.png 1 image11.png 2 image12.png 2 ... image100.png 10 

this prototxt file. in advance

name: "caffenet" input: "data" input_dim: 1 input_dim: 3 input_dim: 227 input_dim: 227 layers {   name: "conv1"   type: convolution   bottom: "data"   top: "conv1"   convolution_param {     num_output: 96     kernel_size: 7     stride: 4   } } layers {   name: "relu1"   type: relu   bottom: "conv1"   top: "conv1" } layers {   name: "pool1"   type: pooling   bottom: "conv1"   top: "pool1"   pooling_param {     pool: max     kernel_size: 3     stride: 2   } } layers {   name: "norm1"   type: lrn   bottom: "pool1"   top: "norm1"   lrn_param {     local_size: 5     alpha: 0.0001     beta: 0.75   } } layers {   name: "conv2"   type: convolution   bottom: "norm1"   top: "conv2"   convolution_param {     num_output: 256     pad: 2     kernel_size: 5   } } layers {   name: "relu2"   type: relu   bottom: "conv2"   top: "conv2" } layers {   name: "pool2"   type: pooling   bottom: "conv2"   top: "pool2"   pooling_param {     pool: max     kernel_size: 3     stride: 2   } } layers {   name: "norm2"   type: lrn   bottom: "pool2"   top: "norm2"   lrn_param {     local_size: 5     alpha: 0.0001     beta: 0.75   } } layers {   name: "conv3"   type: convolution   bottom: "norm2"   top: "conv3"   convolution_param {     num_output: 384     pad: 1     kernel_size: 3   } } layers{   name: "relu3"    type: relu   bottom: "conv3"   top: "conv3" } layers {   name: "pool5"   type: pooling   bottom: "conv3"   top: "pool5"   pooling_param {     pool: max     kernel_size: 3     stride: 2   } } layers {   name: "fc6"   type: inner_product   bottom: "pool5"   top: "fc6"   inner_product_param {     num_output: 512   } } layers {   name: "relu6"   type: relu   bottom: "fc6"   top: "fc6" } layers {   name: "drop6"   type: dropout   bottom: "fc6"   top: "fc6"   dropout_param {     dropout_ratio: 0.5   } } layers {   name: "fc7"   type: inner_product   bottom: "fc6"   top: "fc7"   inner_product_param {     num_output: 512   } } layers {   name: "relu7"   type: relu   bottom: "fc7"   top: "fc7" } layers {   name: "drop7"   type: dropout   bottom: "fc7"   top: "fc7"   dropout_param {     dropout_ratio: 0.5   } } layers {   name: "fc8"   type: inner_product   bottom: "fc7"   top: "fc8"   inner_product_param {     num_output: 8   } } layers {   name: "prob"   type: softmax   bottom: "fc8"   top: "prob" } 

to caffemodel need train network. prototxt file deploy model , cannot used train it.

you need add data layer points database. use list of files mention, source of layer should hdf5. want add transform_param mean value. image files can replaced lmdb or leveldb database efficiency purposes.

at end of network have substitute 'prob' layer 'loss' layer. this:

layers { name: "loss" type: softmaxwithloss bottom: "fc8" top: "loss" }

the layer catalogue can found here:

http://caffe.berkeleyvision.org/tutorial/layers.html

or, network known one... @ tutorial :p.

http://caffe.berkeleyvision.org/gathered/examples/imagenet.html

the correct prototxt file training included in caffe ('train_val.prototxt').


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -