models_VGGNet_VOC0712_SSD_300x300.tar.gz
已训练好的VGGNet模型可导入直接使用。具体使用说明可参考https://blog.csdn.net/u010677365/article/details/80881040。
代码片段和文件信息
from __future__ import print_function
import caffe
from caffe.model_libs import *
from google.protobuf import text_format
import math
import os
import shutil
import stat
import subprocess
import sys
# Add extra layers on top of a “base“ network (e.g. VGGNet or Inception).
def AddExtralayers(net use_batchnorm=True lr_mult=1):
use_relu = True
# Add additional convolutional layers.
# 19 x 19
from_layer = net.keys()[-1]
# TODO(weiliu89): Construct the name using the last layer to avoid duplication.
# 10 x 10
out_layer = “conv6_1“
ConvBNlayer(net from_layer out_layer use_batchnorm use_relu 256 1 0 1
lr_mult=lr_mult)
from_layer = out_layer
out_layer = “conv6_2“
ConvBNlayer(net from_layer out_layer use_batchnorm use_relu 512 3 1 2
lr_mult=lr_mult)
# 5 x 5
from_layer = out_layer
out_layer = “conv7_1“
ConvBNlayer(net from_layer out_layer use_batchnorm use_relu 128 1 0 1
lr_mult=lr_mult)
from_layer = out_layer
out_layer = “conv7_2“
ConvBNlayer(net from_layer out_layer use_batchnorm use_relu 256 3 1 2
lr_mult=lr_mult)
# 3 x 3
from_layer = out_layer
out_layer = “conv8_1“
ConvBNlayer(net from_layer out_layer use_batchnorm use_relu 128 1 0 1
lr_mult=lr_mult)
from_layer = out_layer
out_layer = “conv8_2“
ConvBNlayer(net from_layer out_layer use_batchnorm use_relu 256 3 0 1
lr_mult=lr_mult)
# 1 x 1
from_layer = out_layer
out_layer = “conv9_1“
ConvBNlayer(net from_layer out_layer use_batchnorm use_relu 128 1 0 1
lr_mult=lr_mult)
from_layer = out_layer
out_layer = “conv9_2“
ConvBNlayer(net from_layer out_layer use_batchnorm use_relu 256 3 0 1
lr_mult=lr_mult)
return net
### Modify the following parameters accordingly ###
# Notice: we do evaluation by setting the solver parameters approximately.
# The reason that we do not use ./build/tools/caffe test ... is because it
# only supports testing for classification problem now.
# The directory which contains the caffe code.
# We assume you are running the script at the CAFFE_ROOT.
caffe_root = os.getcwd()
# Set true if you want to start training right after generating all files.
run_soon = True
# The database file for training data. Created by data/VOC0712/create_data.sh
train_data = “examples/VOC0712/VOC0712_trainval_lmdb“
# The database file for testing data. Created by data/VOC0712/create_data.sh
test_data = “examples/VOC0712/VOC0712_test_lmdb“
# Specify the batch sampler.
resize_width = 300
resize_height = 300
resize = “{}x{}“.format(resize_width resize_height)
batch_sampler = [
{
‘sampler‘: {
}
‘max_trials‘: 1
‘max_sample‘: 1
}
{
‘sampler‘: {
‘min_scale‘: 0.3
‘max_scale‘: 1.0
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)