前言:这个作者的思路没什么,改了个网络而已,但是没想到他里面的参数只是随便写的,并不是完全成立,而如果将这些参数设计成SSD 中VGG16的,则可以正确的编译(很难受),把网络留在这里,可以直接替换VGG16部分。最近准备使用kitti数据集进行测试和yolo V3比较
# coding=utf-8
"""Keras implementation of SSD."""
import keras.backend as K
from keras.layers import Activation
from keras.layers import AtrousConvolution2D
from keras.layers import Conv2D
from keras.layers import Dense
from keras.layers import Flatten
from keras.layers import GlobalAveragePooling2D
from keras.layers import Input
from keras.layers import MaxPooling2D
from keras.layers import merge
from keras.layers import Reshape
from keras.layers import ZeroPadding2D
from keras.models import Model, Sequential
from ssd_layers import Normalize
from ssd_layers import PriorBox
from keras.models import Sequential
from keras.layers import Dense, Flatten, Dropout, Concatenate
from keras.layers.convolutional import Conv2D, MaxPooling2D
import numpy as np
def SqueezeNet(inputs, nb_classes=21):
""" Keras Implementation of SqueezeNet(arXiv 1602.07360)
@param nb_classes: total number of final categories
Arguments:
inputs -- shape of the input images (channel, cols, rows)
"""
img_size = (inputs[0], inputs[1])
input_img = (Input(shape=inputs))
conv1 = Conv2D(
64, (3, 3), activation='relu', kernel_initializer='glorot_uniform',
strides=(1, 1), name='conv1', padding='same',
data_format="channels_last")(input_img)
# maxpool1
maxpool1 = MaxPooling2D(
pool_size=(2, 2), strides=(2, 2), name='maxpool1',
data_format="channels_last")(conv1)
# fire1
fire1_squeeze = Conv2D(
15, (1, 1), activation='relu', kernel_initializer='glorot_uniform',
name='fire1_squeeze',
data_format="channels_last")(maxpool1)
fire1_expand1 = Conv2D(
49, (1, 1), activation='relu', kernel_initializer='glorot_uniform',
padding='same', name='fire1_expand1',
data_format="channels_last")(fire1_squeeze)
fire1_expand2 = Conv2D(
53, (3, 3), activation='relu', kernel_initializer='glorot_uniform',
padding='same', name='fire1_expand2',
data_format="channels_last")(fire1_squeeze)
merge1 = Concatenate(axis=3)([fire1_expand1, fire1_expand2])
maxpool2 = MaxPooling2D(
pool_size=(2, 2), strides=(2, 2), name='maxpool2',
data_format="channels_last")(merge1)
# fire2
fire2_squeeze = Conv2D(
15, (1, 1), activation='relu', kernel_initializer='glorot_uniform',
name='fire2_squeeze',
data_format="channels_last")(maxpool2)
fire2_expand1 = Conv2D(
54, (1, 1), activation='relu', kernel_initializer='glorot_uniform',
padding='same', name='fire2_expand1',
data_format="channels_last")(fire2_squeeze)
fire2_expand2 = Conv2D(
52, (3, 3), activation='relu', kernel_initializer='glorot_uniform',
padding='same', name='fire2_expand2',
data_format="channels_last")(fire2_squeeze)
merge2 = Concatenate(axis=3)([fire2_expand1, fire2_expand2])
# maxpool3
maxpool3 = MaxPooling2D(
pool_size=(3, 3), strides=(2, 2), padding='same', name='maxpool3',
data_format="channels_last")(merge2)
# fire3
fire3_squeeze = Conv2D(
29, (1, 1), activation='relu', kernel_initializer='glorot_uniform',
name='fire3_squeeze