yolo.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:mcv-m5 作者: david-vazquez 项目源码 文件源码
def TinyYOLO(input_shape=(3,416,416),num_classes=80,num_priors=5):
    """Tiny YOLO (v2) architecture

    # Arguments
        input_shape: Shape of the input image
        num_classes: Number of classes (excluding background)

    # References
        https://arxiv.org/abs/1612.08242
        https://arxiv.org/abs/1506.02640
    """
    K.set_image_dim_ordering('th')

    net={}
    input_tensor = Input(shape=input_shape)
    net['input'] = input_tensor
    net['conv1'] = (YOLOConvolution2D(16, 3, 3, border_mode='same',subsample=(1,1),
                                      epsilon=0.000001))(net['input'])
    net['relu1'] = (LeakyReLU(alpha=0.1))(net['conv1'])
    net['pool1'] = (MaxPooling2D(pool_size=(2, 2),border_mode='valid'))(net['relu1'])
    net['conv2'] = (YOLOConvolution2D(32, 3, 3, border_mode='same',subsample=(1,1),
                                      epsilon=0.000001))(net['pool1'])
    net['relu2'] = (LeakyReLU(alpha=0.1))(net['conv2'])
    net['pool2'] = (MaxPooling2D(pool_size=(2, 2),border_mode='valid'))(net['relu2'])
    net['conv3'] = (YOLOConvolution2D(64, 3, 3, border_mode='same',subsample=(1,1),
                                      epsilon=0.000001))(net['pool2'])
    net['relu3'] = (LeakyReLU(alpha=0.1))(net['conv3'])
    net['pool3'] = (MaxPooling2D(pool_size=(2, 2),border_mode='valid'))(net['relu3'])
    net['conv4'] = (YOLOConvolution2D(128, 3, 3, border_mode='same',subsample=(1,1),
                                      epsilon=0.000001))(net['pool3'])
    net['relu4'] = (LeakyReLU(alpha=0.1))(net['conv4'])
    net['pool4'] = (MaxPooling2D(pool_size=(2, 2),border_mode='valid'))(net['relu4'])
    net['conv5'] = (YOLOConvolution2D(256, 3, 3, border_mode='same',subsample=(1,1),
                                      epsilon=0.000001))(net['pool4'])
    net['relu5'] = (LeakyReLU(alpha=0.1))(net['conv5'])
    net['pool5'] = (MaxPooling2D(pool_size=(2, 2),border_mode='valid'))(net['relu5'])
    net['conv6'] = (YOLOConvolution2D(512, 3, 3, border_mode='same',subsample=(1,1),
                                      epsilon=0.000001))(net['pool5'])
    net['relu6'] = (LeakyReLU(alpha=0.1))(net['conv6'])
    net['pool6'] = (MaxPooling2D(pool_size=(2, 2),strides=(1,1),border_mode='same'))(net['relu6'])
    net['conv7'] = (YOLOConvolution2D(1024, 3, 3, border_mode='same',subsample=(1,1),
                                      epsilon=0.000001))(net['pool6'])
    net['relu7'] = (LeakyReLU(alpha=0.1))(net['conv7'])
    net['conv8'] = (YOLOConvolution2D(1024, 3, 3, border_mode='same',subsample=(1,1),
                                      epsilon=0.000001))(net['relu7'])
    net['relu8'] = (LeakyReLU(alpha=0.1))(net['conv8'])
    net['conv9'] = (Convolution2D(num_priors*(4+num_classes+1), 1, 1, border_mode='same',
                                              subsample=(1,1)))(net['relu8'])

    model = Model(net['input'], net['conv9'])
    return model
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号