caffe分类网络训练及测试步骤

1.生成txt文件

分类网络可以不用制作lmdb数据,直接用txt文件作为输入源,一般习惯创建一个images文件夹,然后里面每一类单独一个文件夹,每个文件夹里面存放某一类的图片,然后用Python生成txt,脚本如下。

import os
import random


base_dir = "/data/chw/changjing_fenlei_20200622/yugeshuju/images"
f_train = open("./train_origin.txt", 'w')
#f_val = open("./val.txt", 'w')
f_test = open("./test.txt", 'w')
f_label = open("./label.txt", "w")

for root, dirs, files in os.walk(base_dir):
    i = 0
    for dirname in dirs:
        label_name = dirname
        f_label.write(label_name + " " + str(i) + "
")
        path = os.path.join(root, dirname)
        for jpeg_name in os.listdir(path):
            jpeg_path = os.path.join(path, jpeg_name)
            feed = random.randint(0, 10)
            if feed <= 9:
                f_train.write(jpeg_path + " " + str(i) + "
")
            if feed == 10:
                f_test.write(jpeg_path + " " + str(i) + "
")
        i=i + 1
    

f_train.close()
#f_val.close()
f_test.close()
f_label.close()

生成txt文件里面,某一类的图片是紧挨着的,要把它打乱,用下面脚本

import os
import random
out = open("./train.txt",'w')
lines=[]
with open("./train_origin.txt", 'r') as infile:
    for line in infile:
        lines.append(line)
random.shuffle(lines)
random.shuffle(lines)
random.shuffle(lines)
random.shuffle(lines)
random.shuffle(lines)
for line in lines:
    out.write(line)

2.训练

首先修改train.prototxt

例如

# Enter your network definition here.
# Use Shift+Enter to update the visualization.
name: "shufflenet_v2"
layer {
  name: "Data"
  type: "ImageData"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    mirror: true
    mean_value: 104
    mean_value: 117
    mean_value: 123
  }
  image_data_param {
    mirror: true
    source: "./train.txt"  
    #root_folder: "/images/"
    new_height: 224 
    new_ 224  
    batch_size: 8  
    shuffle: true  #每个epoch都会进行shuffle
    #label_dim: 38
   }
}

layer {
  name: "Data"
  type: "ImageData"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  transform_param {
    mean_value: 104
    mean_value: 117
    mean_value: 123
  }
  image_data_param {
    source: "./test.txt"  
    #root_folder: "/images/"
    new_height: 224 
    new_ 224  
    batch_size: 8  
    #label_dim: 38
   }
}
##########################################################
#layer {
#  name: "data"
#  type: "Data"
#  top: "data"
#  top: "label"
#  include {
#    phase: TRAIN
#  }
#  transform_param {
#    mirror: true
#    mean_file: "deepsort_mean.binaryproto"
#  }
#  data_param {
#    source: "deepsort_train_lmdb"
#    batch_size: 10
#    backend: LMDB
#  }
#}
#layer {
#  name: "data"
#  type: "Data"
#  top: "data"
#  top: "label"
#  include {
#    phase: TEST
#  }
#  transform_param {
#    mirror: false
#    mean_file: "deepsort_mean.binaryproto"
#  }
#  data_param {
#    source: "deepsort_val_lmdb"
#    batch_size: 10
#    backend: LMDB
#  }
#}
###########################################
layer {
  name: "conv1"
  type: "Convolution"
  bottom: "data"
  top: "conv1"
  convolution_param {
    num_output: 24
    pad: 1
    kernel_size: 3
    stride: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "conv1_bn"
  type: "BatchNorm"
  bottom: "conv1"
  top: "conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "conv1_scale"
  bottom: "conv1"
  top: "conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "conv1_relu"
  type: "ReLU"
  bottom: "conv1"
  top: "conv1"
}
layer {
  name: "pool1"
  type: "Pooling"
  bottom: "conv1"
  top: "pool1"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "branch1_1_conv1"
  type: "ConvolutionDepthwise"
  bottom: "pool1"
  top: "branch1_1_conv1"
  convolution_param {
    num_output: 24
    kernel_size: 3
    stride: 2
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch1_1_conv1_bn"
  type: "BatchNorm"
  bottom: "branch1_1_conv1"
  top: "branch1_1_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch1_1_conv1_scale"
  bottom: "branch1_1_conv1"
  top: "branch1_1_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch1_1_conv2"
  type: "Convolution"
  bottom: "branch1_1_conv1"
  top: "branch1_1_conv2"
  convolution_param {
    num_output: 58
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch1_1_conv2_bn"
  type: "BatchNorm"
  bottom: "branch1_1_conv2"
  top: "branch1_1_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch1_1_conv2_scale"
  bottom: "branch1_1_conv2"
  top: "branch1_1_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch1_1_conv2_relu"
  type: "ReLU"
  bottom: "branch1_1_conv2"
  top: "branch1_1_conv2"
}
layer {
  name: "branch1_2_conv1"
  type: "Convolution"
  bottom: "pool1"
  top: "branch1_2_conv1"
  convolution_param {
    num_output: 58
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch1_2_conv1_bn"
  type: "BatchNorm"
  bottom: "branch1_2_conv1"
  top: "branch1_2_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch1_2_conv1_scale"
  bottom: "branch1_2_conv1"
  top: "branch1_2_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch1_2_conv1_relu"
  type: "ReLU"
  bottom: "branch1_2_conv1"
  top: "branch1_2_conv1"
}
layer {
  name: "branch1_2_conv2"
  type: "ConvolutionDepthwise"
  bottom: "branch1_2_conv1"
  top: "branch1_2_conv2"
  convolution_param {
    num_output: 58
    kernel_size: 3
    stride: 2
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch1_2_conv2_bn"
  type: "BatchNorm"
  bottom: "branch1_2_conv2"
  top: "branch1_2_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch1_2_conv2_scale"
  bottom: "branch1_2_conv2"
  top: "branch1_2_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch1_2_conv3"
  type: "Convolution"
  bottom: "branch1_2_conv2"
  top: "branch1_2_conv3"
  convolution_param {
    num_output: 58
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch1_2_conv3_bn"
  type: "BatchNorm"
  bottom: "branch1_2_conv3"
  top: "branch1_2_conv3"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch1_2_conv3_scale"
  bottom: "branch1_2_conv3"
  top: "branch1_2_conv3"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch1_2_conv3_relu"
  type: "ReLU"
  bottom: "branch1_2_conv3"
  top: "branch1_2_conv3"
}
layer {
  name: "concat1"
  type: "Concat"
  bottom: "branch1_1_conv2"
  bottom: "branch1_2_conv3"
  top: "concat1"
}
layer {
  name: "shuffle1"
  type: "ShuffleChannel"
  bottom: "concat1"
  top: "shuffle1"
  shuffle_channel_param {
    group: 2
  }
}
layer {
  name: "slice2"
  type: "Slice"
  bottom: "shuffle1"
  top: "branch2_1"
  top: "branch2_2"
  slice_param {
    slice_point: 58
    axis: 1
  }
}
layer {
  name: "branch2_2_conv1"
  type: "Convolution"
  bottom: "branch2_2"
  top: "branch2_2_conv1"
  convolution_param {
    num_output: 58
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch2_2_conv1_bn"
  type: "BatchNorm"
  bottom: "branch2_2_conv1"
  top: "branch2_2_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch2_2_conv1_scale"
  bottom: "branch2_2_conv1"
  top: "branch2_2_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch2_2_conv1_relu"
  type: "ReLU"
  bottom: "branch2_2_conv1"
  top: "branch2_2_conv1"
}
layer {
  name: "branch2_2_conv2"
  type: "ConvolutionDepthwise"
  bottom: "branch2_2_conv1"
  top: "branch2_2_conv2"
  convolution_param {
    num_output: 58
    kernel_size: 3
    stride: 1
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch2_2_conv2_bn"
  type: "BatchNorm"
  bottom: "branch2_2_conv2"
  top: "branch2_2_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch2_2_conv2_scale"
  bottom: "branch2_2_conv2"
  top: "branch2_2_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch2_2_conv3"
  type: "Convolution"
  bottom: "branch2_2_conv2"
  top: "branch2_2_conv3"
  convolution_param {
    num_output: 58
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch2_2_conv3_bn"
  type: "BatchNorm"
  bottom: "branch2_2_conv3"
  top: "branch2_2_conv3"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch2_2_conv3_scale"
  bottom: "branch2_2_conv3"
  top: "branch2_2_conv3"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch2_2_conv3_relu"
  type: "ReLU"
  bottom: "branch2_2_conv3"
  top: "branch2_2_conv3"
}
layer {
  name: "concat2"
  type: "Concat"
  bottom: "branch2_1"
  bottom: "branch2_2_conv3"
  top: "concat2"
}
layer {
  name: "shuffle2"
  type: "ShuffleChannel"
  bottom: "concat2"
  top: "shuffle2"
  shuffle_channel_param {
    group: 2
  }
}
layer {
  name: "slice3"
  type: "Slice"
  bottom: "shuffle2"
  top: "branch3_1"
  top: "branch3_2"
  slice_param {
    slice_point: 58
    axis: 1
  }
}
layer {
  name: "branch3_2_conv1"
  type: "Convolution"
  bottom: "branch3_2"
  top: "branch3_2_conv1"
  convolution_param {
    num_output: 58
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch3_2_conv1_bn"
  type: "BatchNorm"
  bottom: "branch3_2_conv1"
  top: "branch3_2_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch3_2_conv1_scale"
  bottom: "branch3_2_conv1"
  top: "branch3_2_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch3_2_conv1_relu"
  type: "ReLU"
  bottom: "branch3_2_conv1"
  top: "branch3_2_conv1"
}
layer {
  name: "branch3_2_conv2"
  type: "ConvolutionDepthwise"
  bottom: "branch3_2_conv1"
  top: "branch3_2_conv2"
  convolution_param {
    num_output: 58
    kernel_size: 3
    stride: 1
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch3_2_conv2_bn"
  type: "BatchNorm"
  bottom: "branch3_2_conv2"
  top: "branch3_2_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch3_2_conv2_scale"
  bottom: "branch3_2_conv2"
  top: "branch3_2_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch3_2_conv3"
  type: "Convolution"
  bottom: "branch3_2_conv2"
  top: "branch3_2_conv3"
  convolution_param {
    num_output: 58
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch3_2_conv3_bn"
  type: "BatchNorm"
  bottom: "branch3_2_conv3"
  top: "branch3_2_conv3"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch3_2_conv3_scale"
  bottom: "branch3_2_conv3"
  top: "branch3_2_conv3"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch3_2_conv3_relu"
  type: "ReLU"
  bottom: "branch3_2_conv3"
  top: "branch3_2_conv3"
}
layer {
  name: "concat3"
  type: "Concat"
  bottom: "branch3_1"
  bottom: "branch3_2_conv3"
  top: "concat3"
}
layer {
  name: "shuffle3"
  type: "ShuffleChannel"
  bottom: "concat3"
  top: "shuffle3"
  shuffle_channel_param {
    group: 2
  }
}
layer {
  name: "slice4"
  type: "Slice"
  bottom: "shuffle3"
  top: "branch4_1"
  top: "branch4_2"
  slice_param {
    slice_point: 58
    axis: 1
  }
}
layer {
  name: "branch4_2_conv1"
  type: "Convolution"
  bottom: "branch4_2"
  top: "branch4_2_conv1"
  convolution_param {
    num_output: 58
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch4_2_conv1_bn"
  type: "BatchNorm"
  bottom: "branch4_2_conv1"
  top: "branch4_2_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch4_2_conv1_scale"
  bottom: "branch4_2_conv1"
  top: "branch4_2_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch4_2_conv1_relu"
  type: "ReLU"
  bottom: "branch4_2_conv1"
  top: "branch4_2_conv1"
}
layer {
  name: "branch4_2_conv2"
  type: "ConvolutionDepthwise"
  bottom: "branch4_2_conv1"
  top: "branch4_2_conv2"
  convolution_param {
    num_output: 58
    kernel_size: 3
    stride: 1
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch4_2_conv2_bn"
  type: "BatchNorm"
  bottom: "branch4_2_conv2"
  top: "branch4_2_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch4_2_conv2_scale"
  bottom: "branch4_2_conv2"
  top: "branch4_2_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch4_2_conv3"
  type: "Convolution"
  bottom: "branch4_2_conv2"
  top: "branch4_2_conv3"
  convolution_param {
    num_output: 58
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch4_2_conv3_bn"
  type: "BatchNorm"
  bottom: "branch4_2_conv3"
  top: "branch4_2_conv3"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch4_2_conv3_scale"
  bottom: "branch4_2_conv3"
  top: "branch4_2_conv3"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch4_2_conv3_relu"
  type: "ReLU"
  bottom: "branch4_2_conv3"
  top: "branch4_2_conv3"
}
layer {
  name: "concat4"
  type: "Concat"
  bottom: "branch4_1"
  bottom: "branch4_2_conv3"
  top: "concat4"
}
layer {
  name: "shuffle4"
  type: "ShuffleChannel"
  bottom: "concat4"
  top: "shuffle4"
  shuffle_channel_param {
    group: 2
  }
}
layer {
  name: "branch5_1_conv1"
  type: "ConvolutionDepthwise"
  bottom: "shuffle4"
  top: "branch5_1_conv1"
  convolution_param {
    num_output: 116
    kernel_size: 3
    stride: 2
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch5_1_conv1_bn"
  type: "BatchNorm"
  bottom: "branch5_1_conv1"
  top: "branch5_1_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch5_1_conv1_scale"
  bottom: "branch5_1_conv1"
  top: "branch5_1_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch5_1_conv2"
  type: "Convolution"
  bottom: "branch5_1_conv1"
  top: "branch5_1_conv2"
  convolution_param {
    num_output: 116
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch5_1_conv2_bn"
  type: "BatchNorm"
  bottom: "branch5_1_conv2"
  top: "branch5_1_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch5_1_conv2_scale"
  bottom: "branch5_1_conv2"
  top: "branch5_1_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch5_1_conv2_relu"
  type: "ReLU"
  bottom: "branch5_1_conv2"
  top: "branch5_1_conv2"
}
layer {
  name: "branch5_2_conv1"
  type: "Convolution"
  bottom: "shuffle4"
  top: "branch5_2_conv1"
  convolution_param {
    num_output: 116
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch5_2_conv1_bn"
  type: "BatchNorm"
  bottom: "branch5_2_conv1"
  top: "branch5_2_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch5_2_conv1_scale"
  bottom: "branch5_2_conv1"
  top: "branch5_2_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch5_2_conv1_relu"
  type: "ReLU"
  bottom: "branch5_2_conv1"
  top: "branch5_2_conv1"
}
layer {
  name: "branch5_2_conv2"
  type: "ConvolutionDepthwise"
  bottom: "branch5_2_conv1"
  top: "branch5_2_conv2"
  convolution_param {
    num_output: 116
    kernel_size: 3
    stride: 2
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch5_2_conv2_bn"
  type: "BatchNorm"
  bottom: "branch5_2_conv2"
  top: "branch5_2_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch5_2_conv2_scale"
  bottom: "branch5_2_conv2"
  top: "branch5_2_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch5_2_conv3"
  type: "Convolution"
  bottom: "branch5_2_conv2"
  top: "branch5_2_conv3"
  convolution_param {
    num_output: 116
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch5_2_conv3_bn"
  type: "BatchNorm"
  bottom: "branch5_2_conv3"
  top: "branch5_2_conv3"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch5_2_conv3_scale"
  bottom: "branch5_2_conv3"
  top: "branch5_2_conv3"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch5_2_conv3_relu"
  type: "ReLU"
  bottom: "branch5_2_conv3"
  top: "branch5_2_conv3"
}
layer {
  name: "concat5"
  type: "Concat"
  bottom: "branch5_1_conv2"
  bottom: "branch5_2_conv3"
  top: "concat5"
}
layer {
  name: "shuffle5"
  type: "ShuffleChannel"
  bottom: "concat5"
  top: "shuffle5"
  shuffle_channel_param {
    group: 2
  }
}
layer {
  name: "slice6"
  type: "Slice"
  bottom: "shuffle5"
  top: "branch6_1"
  top: "branch6_2"
  slice_param {
    slice_point: 116
    axis: 1
  }
}
layer {
  name: "branch6_2_conv1"
  type: "Convolution"
  bottom: "branch6_2"
  top: "branch6_2_conv1"
  convolution_param {
    num_output: 116
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch6_2_conv1_bn"
  type: "BatchNorm"
  bottom: "branch6_2_conv1"
  top: "branch6_2_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch6_2_conv1_scale"
  bottom: "branch6_2_conv1"
  top: "branch6_2_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch6_2_conv1_relu"
  type: "ReLU"
  bottom: "branch6_2_conv1"
  top: "branch6_2_conv1"
}
layer {
  name: "branch6_2_conv2"
  type: "ConvolutionDepthwise"
  bottom: "branch6_2_conv1"
  top: "branch6_2_conv2"
  convolution_param {
    num_output: 116
    kernel_size: 3
    stride: 1
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch6_2_conv2_bn"
  type: "BatchNorm"
  bottom: "branch6_2_conv2"
  top: "branch6_2_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch6_2_conv2_scale"
  bottom: "branch6_2_conv2"
  top: "branch6_2_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch6_2_conv3"
  type: "Convolution"
  bottom: "branch6_2_conv2"
  top: "branch6_2_conv3"
  convolution_param {
    num_output: 116
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch6_2_conv3_bn"
  type: "BatchNorm"
  bottom: "branch6_2_conv3"
  top: "branch6_2_conv3"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch6_2_conv3_scale"
  bottom: "branch6_2_conv3"
  top: "branch6_2_conv3"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch6_2_conv3_relu"
  type: "ReLU"
  bottom: "branch6_2_conv3"
  top: "branch6_2_conv3"
}
layer {
  name: "concat6"
  type: "Concat"
  bottom: "branch6_1"
  bottom: "branch6_2_conv3"
  top: "concat6"
}
layer {
  name: "shuffle6"
  type: "ShuffleChannel"
  bottom: "concat6"
  top: "shuffle6"
  shuffle_channel_param {
    group: 2
  }
}
layer {
  name: "slice7"
  type: "Slice"
  bottom: "shuffle6"
  top: "branch7_1"
  top: "branch7_2"
  slice_param {
    slice_point: 116
    axis: 1
  }
}
layer {
  name: "branch7_2_conv1"
  type: "Convolution"
  bottom: "branch7_2"
  top: "branch7_2_conv1"
  convolution_param {
    num_output: 116
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch7_2_conv1_bn"
  type: "BatchNorm"
  bottom: "branch7_2_conv1"
  top: "branch7_2_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch7_2_conv1_scale"
  bottom: "branch7_2_conv1"
  top: "branch7_2_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch7_2_conv1_relu"
  type: "ReLU"
  bottom: "branch7_2_conv1"
  top: "branch7_2_conv1"
}
layer {
  name: "branch7_2_conv2"
  type: "ConvolutionDepthwise"
  bottom: "branch7_2_conv1"
  top: "branch7_2_conv2"
  convolution_param {
    num_output: 116
    kernel_size: 3
    stride: 1
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch7_2_conv2_bn"
  type: "BatchNorm"
  bottom: "branch7_2_conv2"
  top: "branch7_2_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch7_2_conv2_scale"
  bottom: "branch7_2_conv2"
  top: "branch7_2_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch7_2_conv3"
  type: "Convolution"
  bottom: "branch7_2_conv2"
  top: "branch7_2_conv3"
  convolution_param {
    num_output: 116
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch7_2_conv3_bn"
  type: "BatchNorm"
  bottom: "branch7_2_conv3"
  top: "branch7_2_conv3"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch7_2_conv3_scale"
  bottom: "branch7_2_conv3"
  top: "branch7_2_conv3"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch7_2_conv3_relu"
  type: "ReLU"
  bottom: "branch7_2_conv3"
  top: "branch7_2_conv3"
}
layer {
  name: "concat7"
  type: "Concat"
  bottom: "branch7_1"
  bottom: "branch7_2_conv3"
  top: "concat7"
}
layer {
  name: "shuffle7"
  type: "ShuffleChannel"
  bottom: "concat7"
  top: "shuffle7"
  shuffle_channel_param {
    group: 2
  }
}
layer {
  name: "slice8"
  type: "Slice"
  bottom: "shuffle7"
  top: "branch8_1"
  top: "branch8_2"
  slice_param {
    slice_point: 116
    axis: 1
  }
}
layer {
  name: "branch8_2_conv1"
  type: "Convolution"
  bottom: "branch8_2"
  top: "branch8_2_conv1"
  convolution_param {
    num_output: 116
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch8_2_conv1_bn"
  type: "BatchNorm"
  bottom: "branch8_2_conv1"
  top: "branch8_2_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch8_2_conv1_scale"
  bottom: "branch8_2_conv1"
  top: "branch8_2_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch8_2_conv1_relu"
  type: "ReLU"
  bottom: "branch8_2_conv1"
  top: "branch8_2_conv1"
}
layer {
  name: "branch8_2_conv2"
  type: "ConvolutionDepthwise"
  bottom: "branch8_2_conv1"
  top: "branch8_2_conv2"
  convolution_param {
    num_output: 116
    kernel_size: 3
    stride: 1
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch8_2_conv2_bn"
  type: "BatchNorm"
  bottom: "branch8_2_conv2"
  top: "branch8_2_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch8_2_conv2_scale"
  bottom: "branch8_2_conv2"
  top: "branch8_2_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch8_2_conv3"
  type: "Convolution"
  bottom: "branch8_2_conv2"
  top: "branch8_2_conv3"
  convolution_param {
    num_output: 116
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch8_2_conv3_bn"
  type: "BatchNorm"
  bottom: "branch8_2_conv3"
  top: "branch8_2_conv3"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch8_2_conv3_scale"
  bottom: "branch8_2_conv3"
  top: "branch8_2_conv3"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch8_2_conv3_relu"
  type: "ReLU"
  bottom: "branch8_2_conv3"
  top: "branch8_2_conv3"
}
layer {
  name: "concat8"
  type: "Concat"
  bottom: "branch8_1"
  bottom: "branch8_2_conv3"
  top: "concat8"
}
layer {
  name: "shuffle8"
  type: "ShuffleChannel"
  bottom: "concat8"
  top: "shuffle8"
  shuffle_channel_param {
    group: 2
  }
}
layer {
  name: "slice9"
  type: "Slice"
  bottom: "shuffle8"
  top: "branch9_1"
  top: "branch9_2"
  slice_param {
    slice_point: 116
    axis: 1
  }
}
layer {
  name: "branch9_2_conv1"
  type: "Convolution"
  bottom: "branch9_2"
  top: "branch9_2_conv1"
  convolution_param {
    num_output: 116
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch9_2_conv1_bn"
  type: "BatchNorm"
  bottom: "branch9_2_conv1"
  top: "branch9_2_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch9_2_conv1_scale"
  bottom: "branch9_2_conv1"
  top: "branch9_2_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch9_2_conv1_relu"
  type: "ReLU"
  bottom: "branch9_2_conv1"
  top: "branch9_2_conv1"
}
layer {
  name: "branch9_2_conv2"
  type: "ConvolutionDepthwise"
  bottom: "branch9_2_conv1"
  top: "branch9_2_conv2"
  convolution_param {
    num_output: 116
    kernel_size: 3
    stride: 1
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch9_2_conv2_bn"
  type: "BatchNorm"
  bottom: "branch9_2_conv2"
  top: "branch9_2_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch9_2_conv2_scale"
  bottom: "branch9_2_conv2"
  top: "branch9_2_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch9_2_conv3"
  type: "Convolution"
  bottom: "branch9_2_conv2"
  top: "branch9_2_conv3"
  convolution_param {
    num_output: 116
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch9_2_conv3_bn"
  type: "BatchNorm"
  bottom: "branch9_2_conv3"
  top: "branch9_2_conv3"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch9_2_conv3_scale"
  bottom: "branch9_2_conv3"
  top: "branch9_2_conv3"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch9_2_conv3_relu"
  type: "ReLU"
  bottom: "branch9_2_conv3"
  top: "branch9_2_conv3"
}
layer {
  name: "concat9"
  type: "Concat"
  bottom: "branch9_1"
  bottom: "branch9_2_conv3"
  top: "concat9"
}
layer {
  name: "shuffle9"
  type: "ShuffleChannel"
  bottom: "concat9"
  top: "shuffle9"
  shuffle_channel_param {
    group: 2
  }
}
layer {
  name: "slice10"
  type: "Slice"
  bottom: "shuffle9"
  top: "branch10_1"
  top: "branch10_2"
  slice_param {
    slice_point: 116
    axis: 1
  }
}
layer {
  name: "branch10_2_conv1"
  type: "Convolution"
  bottom: "branch10_2"
  top: "branch10_2_conv1"
  convolution_param {
    num_output: 116
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch10_2_conv1_bn"
  type: "BatchNorm"
  bottom: "branch10_2_conv1"
  top: "branch10_2_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch10_2_conv1_scale"
  bottom: "branch10_2_conv1"
  top: "branch10_2_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch10_2_conv1_relu"
  type: "ReLU"
  bottom: "branch10_2_conv1"
  top: "branch10_2_conv1"
}
layer {
  name: "branch10_2_conv2"
  type: "ConvolutionDepthwise"
  bottom: "branch10_2_conv1"
  top: "branch10_2_conv2"
  convolution_param {
    num_output: 116
    kernel_size: 3
    stride: 1
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch10_2_conv2_bn"
  type: "BatchNorm"
  bottom: "branch10_2_conv2"
  top: "branch10_2_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch10_2_conv2_scale"
  bottom: "branch10_2_conv2"
  top: "branch10_2_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch10_2_conv3"
  type: "Convolution"
  bottom: "branch10_2_conv2"
  top: "branch10_2_conv3"
  convolution_param {
    num_output: 116
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch10_2_conv3_bn"
  type: "BatchNorm"
  bottom: "branch10_2_conv3"
  top: "branch10_2_conv3"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch10_2_conv3_scale"
  bottom: "branch10_2_conv3"
  top: "branch10_2_conv3"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch10_2_conv3_relu"
  type: "ReLU"
  bottom: "branch10_2_conv3"
  top: "branch10_2_conv3"
}
layer {
  name: "concat10"
  type: "Concat"
  bottom: "branch10_1"
  bottom: "branch10_2_conv3"
  top: "concat10"
}
layer {
  name: "shuffle10"
  type: "ShuffleChannel"
  bottom: "concat10"
  top: "shuffle10"
  shuffle_channel_param {
    group: 2
  }
}
layer {
  name: "slice11"
  type: "Slice"
  bottom: "shuffle10"
  top: "branch11_1"
  top: "branch11_2"
  slice_param {
    slice_point: 116
    axis: 1
  }
}
layer {
  name: "branch11_2_conv1"
  type: "Convolution"
  bottom: "branch11_2"
  top: "branch11_2_conv1"
  convolution_param {
    num_output: 116
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch11_2_conv1_bn"
  type: "BatchNorm"
  bottom: "branch11_2_conv1"
  top: "branch11_2_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch11_2_conv1_scale"
  bottom: "branch11_2_conv1"
  top: "branch11_2_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch11_2_conv1_relu"
  type: "ReLU"
  bottom: "branch11_2_conv1"
  top: "branch11_2_conv1"
}
layer {
  name: "branch11_2_conv2"
  type: "ConvolutionDepthwise"
  bottom: "branch11_2_conv1"
  top: "branch11_2_conv2"
  convolution_param {
    num_output: 116
    kernel_size: 3
    stride: 1
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch11_2_conv2_bn"
  type: "BatchNorm"
  bottom: "branch11_2_conv2"
  top: "branch11_2_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch11_2_conv2_scale"
  bottom: "branch11_2_conv2"
  top: "branch11_2_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch11_2_conv3"
  type: "Convolution"
  bottom: "branch11_2_conv2"
  top: "branch11_2_conv3"
  convolution_param {
    num_output: 116
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch11_2_conv3_bn"
  type: "BatchNorm"
  bottom: "branch11_2_conv3"
  top: "branch11_2_conv3"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch11_2_conv3_scale"
  bottom: "branch11_2_conv3"
  top: "branch11_2_conv3"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch11_2_conv3_relu"
  type: "ReLU"
  bottom: "branch11_2_conv3"
  top: "branch11_2_conv3"
}
layer {
  name: "concat11"
  type: "Concat"
  bottom: "branch11_1"
  bottom: "branch11_2_conv3"
  top: "concat11"
}
layer {
  name: "shuffle11"
  type: "ShuffleChannel"
  bottom: "concat11"
  top: "shuffle11"
  shuffle_channel_param {
    group: 2
  }
}
layer {
  name: "slice12"
  type: "Slice"
  bottom: "shuffle11"
  top: "branch12_1"
  top: "branch12_2"
  slice_param {
    slice_point: 116
    axis: 1
  }
}
layer {
  name: "branch12_2_conv1"
  type: "Convolution"
  bottom: "branch12_2"
  top: "branch12_2_conv1"
  convolution_param {
    num_output: 116
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch12_2_conv1_bn"
  type: "BatchNorm"
  bottom: "branch12_2_conv1"
  top: "branch12_2_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch12_2_conv1_scale"
  bottom: "branch12_2_conv1"
  top: "branch12_2_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch12_2_conv1_relu"
  type: "ReLU"
  bottom: "branch12_2_conv1"
  top: "branch12_2_conv1"
}
layer {
  name: "branch12_2_conv2"
  type: "ConvolutionDepthwise"
  bottom: "branch12_2_conv1"
  top: "branch12_2_conv2"
  convolution_param {
    num_output: 116
    kernel_size: 3
    stride: 1
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch12_2_conv2_bn"
  type: "BatchNorm"
  bottom: "branch12_2_conv2"
  top: "branch12_2_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch12_2_conv2_scale"
  bottom: "branch12_2_conv2"
  top: "branch12_2_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch12_2_conv3"
  type: "Convolution"
  bottom: "branch12_2_conv2"
  top: "branch12_2_conv3"
  convolution_param {
    num_output: 116
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch12_2_conv3_bn"
  type: "BatchNorm"
  bottom: "branch12_2_conv3"
  top: "branch12_2_conv3"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch12_2_conv3_scale"
  bottom: "branch12_2_conv3"
  top: "branch12_2_conv3"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch12_2_conv3_relu"
  type: "ReLU"
  bottom: "branch12_2_conv3"
  top: "branch12_2_conv3"
}
layer {
  name: "concat12"
  type: "Concat"
  bottom: "branch12_1"
  bottom: "branch12_2_conv3"
  top: "concat12"
}
layer {
  name: "shuffle12"
  type: "ShuffleChannel"
  bottom: "concat12"
  top: "shuffle12"
  shuffle_channel_param {
    group: 2
  }
}
layer {
  name: "branch13_1_conv1"
  type: "ConvolutionDepthwise"
  bottom: "shuffle12"
  top: "branch13_1_conv1"
  convolution_param {
    num_output: 232
    kernel_size: 3
    stride: 2
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch13_1_conv1_bn"
  type: "BatchNorm"
  bottom: "branch13_1_conv1"
  top: "branch13_1_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch13_1_conv1_scale"
  bottom: "branch13_1_conv1"
  top: "branch13_1_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch13_1_conv2"
  type: "Convolution"
  bottom: "branch13_1_conv1"
  top: "branch13_1_conv2"
  convolution_param {
    num_output: 232
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch13_1_conv2_bn"
  type: "BatchNorm"
  bottom: "branch13_1_conv2"
  top: "branch13_1_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch13_1_conv2_scale"
  bottom: "branch13_1_conv2"
  top: "branch13_1_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch13_1_conv2_relu"
  type: "ReLU"
  bottom: "branch13_1_conv2"
  top: "branch13_1_conv2"
}
layer {
  name: "branch13_2_conv1"
  type: "Convolution"
  bottom: "shuffle12"
  top: "branch13_2_conv1"
  convolution_param {
    num_output: 232
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch13_2_conv1_bn"
  type: "BatchNorm"
  bottom: "branch13_2_conv1"
  top: "branch13_2_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch13_2_conv1_scale"
  bottom: "branch13_2_conv1"
  top: "branch13_2_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch13_2_conv1_relu"
  type: "ReLU"
  bottom: "branch13_2_conv1"
  top: "branch13_2_conv1"
}
layer {
  name: "branch13_2_conv2"
  type: "ConvolutionDepthwise"
  bottom: "branch13_2_conv1"
  top: "branch13_2_conv2"
  convolution_param {
    num_output: 232
    kernel_size: 3
    stride: 2
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch13_2_conv2_bn"
  type: "BatchNorm"
  bottom: "branch13_2_conv2"
  top: "branch13_2_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch13_2_conv2_scale"
  bottom: "branch13_2_conv2"
  top: "branch13_2_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch13_2_conv3"
  type: "Convolution"
  bottom: "branch13_2_conv2"
  top: "branch13_2_conv3"
  convolution_param {
    num_output: 232
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch13_2_conv3_bn"
  type: "BatchNorm"
  bottom: "branch13_2_conv3"
  top: "branch13_2_conv3"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch13_2_conv3_scale"
  bottom: "branch13_2_conv3"
  top: "branch13_2_conv3"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch13_2_conv3_relu"
  type: "ReLU"
  bottom: "branch13_2_conv3"
  top: "branch13_2_conv3"
}
layer {
  name: "concat13"
  type: "Concat"
  bottom: "branch13_1_conv2"
  bottom: "branch13_2_conv3"
  top: "concat13"
}
layer {
  name: "shuffle13"
  type: "ShuffleChannel"
  bottom: "concat13"
  top: "shuffle13"
  shuffle_channel_param {
    group: 2
  }
}
layer {
  name: "slice14"
  type: "Slice"
  bottom: "shuffle13"
  top: "branch14_1"
  top: "branch14_2"
  slice_param {
    slice_point: 232
    axis: 1
  }
}
layer {
  name: "branch14_2_conv1"
  type: "Convolution"
  bottom: "branch14_2"
  top: "branch14_2_conv1"
  convolution_param {
    num_output: 232
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch14_2_conv1_bn"
  type: "BatchNorm"
  bottom: "branch14_2_conv1"
  top: "branch14_2_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch14_2_conv1_scale"
  bottom: "branch14_2_conv1"
  top: "branch14_2_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch14_2_conv1_relu"
  type: "ReLU"
  bottom: "branch14_2_conv1"
  top: "branch14_2_conv1"
}
layer {
  name: "branch14_2_conv2"
  type: "ConvolutionDepthwise"
  bottom: "branch14_2_conv1"
  top: "branch14_2_conv2"
  convolution_param {
    num_output: 232
    kernel_size: 3
    stride: 1
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch14_2_conv2_bn"
  type: "BatchNorm"
  bottom: "branch14_2_conv2"
  top: "branch14_2_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch14_2_conv2_scale"
  bottom: "branch14_2_conv2"
  top: "branch14_2_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch14_2_conv3"
  type: "Convolution"
  bottom: "branch14_2_conv2"
  top: "branch14_2_conv3"
  convolution_param {
    num_output: 232
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch14_2_conv3_bn"
  type: "BatchNorm"
  bottom: "branch14_2_conv3"
  top: "branch14_2_conv3"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch14_2_conv3_scale"
  bottom: "branch14_2_conv3"
  top: "branch14_2_conv3"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch14_2_conv3_relu"
  type: "ReLU"
  bottom: "branch14_2_conv3"
  top: "branch14_2_conv3"
}
layer {
  name: "concat14"
  type: "Concat"
  bottom: "branch14_1"
  bottom: "branch14_2_conv3"
  top: "concat14"
}
layer {
  name: "shuffle14"
  type: "ShuffleChannel"
  bottom: "concat14"
  top: "shuffle14"
  shuffle_channel_param {
    group: 2
  }
}
layer {
  name: "slice15"
  type: "Slice"
  bottom: "shuffle14"
  top: "branch15_1"
  top: "branch15_2"
  slice_param {
    slice_point: 232
    axis: 1
  }
}
layer {
  name: "branch15_2_conv1"
  type: "Convolution"
  bottom: "branch15_2"
  top: "branch15_2_conv1"
  convolution_param {
    num_output: 232
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch15_2_conv1_bn"
  type: "BatchNorm"
  bottom: "branch15_2_conv1"
  top: "branch15_2_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch15_2_conv1_scale"
  bottom: "branch15_2_conv1"
  top: "branch15_2_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch15_2_conv1_relu"
  type: "ReLU"
  bottom: "branch15_2_conv1"
  top: "branch15_2_conv1"
}
layer {
  name: "branch15_2_conv2"
  type: "ConvolutionDepthwise"
  bottom: "branch15_2_conv1"
  top: "branch15_2_conv2"
  convolution_param {
    num_output: 232
    kernel_size: 3
    stride: 1
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch15_2_conv2_bn"
  type: "BatchNorm"
  bottom: "branch15_2_conv2"
  top: "branch15_2_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch15_2_conv2_scale"
  bottom: "branch15_2_conv2"
  top: "branch15_2_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch15_2_conv3"
  type: "Convolution"
  bottom: "branch15_2_conv2"
  top: "branch15_2_conv3"
  convolution_param {
    num_output: 232
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch15_2_conv3_bn"
  type: "BatchNorm"
  bottom: "branch15_2_conv3"
  top: "branch15_2_conv3"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch15_2_conv3_scale"
  bottom: "branch15_2_conv3"
  top: "branch15_2_conv3"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch15_2_conv3_relu"
  type: "ReLU"
  bottom: "branch15_2_conv3"
  top: "branch15_2_conv3"
}
layer {
  name: "concat15"
  type: "Concat"
  bottom: "branch15_1"
  bottom: "branch15_2_conv3"
  top: "concat15"
}
layer {
  name: "shuffle15"
  type: "ShuffleChannel"
  bottom: "concat15"
  top: "shuffle15"
  shuffle_channel_param {
    group: 2
  }
}
layer {
  name: "slice16"
  type: "Slice"
  bottom: "shuffle15"
  top: "branch16_1"
  top: "branch16_2"
  slice_param {
    slice_point: 232
    axis: 1
  }
}
layer {
  name: "branch16_2_conv1"
  type: "Convolution"
  bottom: "branch16_2"
  top: "branch16_2_conv1"
  convolution_param {
    num_output: 232
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch16_2_conv1_bn"
  type: "BatchNorm"
  bottom: "branch16_2_conv1"
  top: "branch16_2_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch16_2_conv1_scale"
  bottom: "branch16_2_conv1"
  top: "branch16_2_conv1"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch16_2_conv1_relu"
  type: "ReLU"
  bottom: "branch16_2_conv1"
  top: "branch16_2_conv1"
}
layer {
  name: "branch16_2_conv2"
  type: "ConvolutionDepthwise"
  bottom: "branch16_2_conv1"
  top: "branch16_2_conv2"
  convolution_param {
    num_output: 232
    kernel_size: 3
    stride: 1
    pad: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch16_2_conv2_bn"
  type: "BatchNorm"
  bottom: "branch16_2_conv2"
  top: "branch16_2_conv2"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch16_2_conv2_scale"
  bottom: "branch16_2_conv2"
  top: "branch16_2_conv2"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch16_2_conv3"
  type: "Convolution"
  bottom: "branch16_2_conv2"
  top: "branch16_2_conv3"
  convolution_param {
    num_output: 232
    kernel_size: 1
    stride: 1
    pad: 0
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "branch16_2_conv3_bn"
  type: "BatchNorm"
  bottom: "branch16_2_conv3"
  top: "branch16_2_conv3"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "branch16_2_conv3_scale"
  bottom: "branch16_2_conv3"
  top: "branch16_2_conv3"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "branch16_2_conv3_relu"
  type: "ReLU"
  bottom: "branch16_2_conv3"
  top: "branch16_2_conv3"
}
layer {
  name: "concat16"
  type: "Concat"
  bottom: "branch16_1"
  bottom: "branch16_2_conv3"
  top: "concat16"
}
layer {
  name: "shuffle16"
  type: "ShuffleChannel"
  bottom: "concat16"
  top: "shuffle16"
  shuffle_channel_param {
    group: 2
  }
}
layer {
  name: "conv5"
  type: "Convolution"
  bottom: "shuffle16"
  top: "conv5"
  convolution_param {
    num_output: 1024
    pad: 0
    kernel_size: 1
    stride: 1
    bias_term: false
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "conv5_bn"
  type: "BatchNorm"
  bottom: "conv5"
  top: "conv5"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "conv5_scale"
  bottom: "conv5"
  top: "conv5"
  type: "Scale"
  scale_param {
    filler {
      value: 1
    }
    bias_term: true
    bias_filler {
      value: 0
    }
  }
}
layer {
  name: "conv5_relu"
  type: "ReLU"
  bottom: "conv5"
  top: "conv5"
}
layer {
  name: "pool_ave"
  type: "Pooling"
  bottom: "conv5"
  top: "pool_ave"
  pooling_param {
    global_pooling : true
    pool: AVE
  }
}
#####################################################################3
layer
{
  name: "featuremap_"
  type: "InnerProduct"
  bottom: "pool_ave"
  top: "featuremap_"
  param{
    lr_mult: 1
    decay_mult: 1
  }
  param{
    lr_mult: 2
    decay_mult: 0
  }
  inner_product_param{
    num_output:256
    weight_filler{
      type: "xavier"
    }
    bias_filler{
      type: "constant"
      value: 0
    }
  }
}
##############################################################################
layer {
  name: "fc6_"
  type: "InnerProduct"
  bottom: "featuremap_"
  top: "fc6_"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  inner_product_param {
    #num_output: 4872
    num_output: 15
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}
layer {
  name: "softmax_loss_"
  type: "SoftmaxWithLoss"
  bottom: "fc6_"
  bottom: "label"
  top: "softmax_loss_"
}
layer
{
  name:"accuracy_"
  type:"Accuracy"
  bottom:"fc6_"
  bottom:"label"
  top:"accuracy_"
  include:{
    phase:TEST
  }
}

然后是solver

net: "/data/chw/changjing_fenlei_20200622/yugeshuju/train_val.prototxt"
test_iter: 100            
test_interval:  1000        
base_lr: 0.0001
lr_policy: "multistep"
#stepsize: 10000
gamma: 0.1
stepvalue: 32000
stepvalue: 48000
stepvalue: 56000
display: 400

#average_loss: 100
max_iter: 100000
momentum: 0.9
weight_decay: 0.005
snapshot: 5000
snapshot_prefix: "./result/changjing"
solver_mode: GPU
#device_id: [2]
#test_initialization: true

然后就可以用下面的命令进行训练了

nohup /data/chw/refinedet/build/tools/caffe train --solver=./solver.prototxt --weights=pretrain.caffemodel --gpu=0,1,2 >&log.txt &

 3.测试

训练完成之后可以用Python接口进行测试,Python脚本如下

#coding=utf-8
import numpy as np
import cv2
import os
import shutil
#caffe_root = '/data/chw/refinedet'
import sys
#os.chdir(caffe_root)
#sys.path.insert(0, 'python')
import caffe
import pdb
import time
caffe.set_device(0)
caffe.set_mode_gpu()
#model_weights = '/data/chw/haixin_rentou_20200525/_iter_200000.caffemodel'
model_weights = '/data/chw/car_class_small_big_20200616/result/ShuffleNet_srn_iter_165000.caffemodel'
model_def = '/data/chw/car_class_small_big_20200616/deploy.prototxt'
net = caffe.Net(model_def, model_weights, caffe.TEST)

total_num=0
correct_num=0


f_result = open("./test_result.txt", "w")



f = open("/data/chw/car_class_small_big_20200616/test.txt")
lines = f.readlines()


for line in lines:
    if ".jpg" in line:
        image_path = line.split(".jpg")[0] +".jpg"
        label = line.split(".jpg")[1].split(" ")[1]
    else:
        image_path = line.split(".jpeg")[0] +".jpeg"
        label = line.split(".jpeg")[1].split(" ")[1]
    print(image_path)
    print(label)
    #time.sleep(100)
    total_num = total_num + 1


#for image_name in os.listdir("/data/chw/car_class_small_big_20200616/test_folder"):
    #image_path= os.path.join("test_folder",image_name)
    image= cv2.imread(image_path)
    re_size = 224
    image = cv2.resize(image,(re_size,re_size))
    time_start=time.time()
    net.blobs['data'].reshape(1, 3, image.shape[0], image.shape[1])
    transformer = caffe.io.Transformer({'data': net. blobs['data'].data.shape})
    transformer.set_transpose('data', (2, 0, 1))
    mean_file=np.array([104,117,123])
    transformer.set_mean("data",mean_file)
    transformed_image = transformer.preprocess('data', image)
    net.blobs['data'].data[...] = transformed_image
    time_end=time.time()
    process_t = (time_end-time_start)*1000
    time_start=time.time()
    output= net.forward()
    detections=output['conf_softmax']
    print(detections)
    if detections[0][0] == max(detections[0]):
        label_result = "0"
        print("label_result:", label_result)
    elif detections[0][1] == max(detections[0]):
        label_result = "1"
        print("label_result:", label_result)
    if str(label.split("
")[0]) == label_result:
        correct_num = correct_num + 1
    elif str(label.split("
")[0]) != label_result:
        copy_path =  os.path.join("/data/chw/car_class_small_big_20200616/test_folder/", str(detections[0]) + "__" + str(label) + os.path.split(image_path)[1])
        shutil.copy(image_path, copy_path);     

    
    f_result.write(image_path + " ")
    f_result.write(str(detections))
    f_result.write(" " + label + "
")
    print("-------------------------------------------------------------------------------------")            

print("correct_num:", correct_num)
print("total_num:", total_num)


f_result.close()
f.close()

作者:cumtchw
出处:http://www.cnblogs.com/cumtchw/
我的博客就是我的学习笔记,学习过程中看到好的博客也会转载过来,若有侵权,与我联系,我会及时删除。

原文地址:https://www.cnblogs.com/cumtchw/p/12582411.html