ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

HyperLPR 高性能中文车牌识别系统分析(一)

2021-10-11 00:00:28  阅读:318  来源: 互联网

标签:HyperLPR name image 系统分析 shape input model 车牌 Activation


2021SC@SDUSC

概述

此次文章主要分析finemapping_vertical.py文件

 调用的库

#coding=utf-8
from keras.layers import Conv2D, Input,MaxPool2D, Reshape,Activation,Flatten, Dense
from keras.models import Model, Sequential
from keras.layers.advanced_activations import PReLU
from keras.optimizers import adam
import numpy as np

import cv2

由代码可知,主要调用的库为keras、cv2

keras

Keras是一个高层神经网络API,Keras由纯Python编写而成并基TensorflowTheano以及CNTK后端。Keras 为支持快速实验而生,能够把你的idea迅速转换为结果

以下是keras的框架架构

代码分析

def getModel():
    input = Input(shape=[16, 66, 3])  # change this shape to [None,None,3] to enable arbitraty shape input
    #将此形状更改为[None,None,3]以启用仲裁形状输入
    x = Conv2D(10, (3, 3), strides=1, padding='valid', name='conv1')(input)
    x = Activation("relu", name='relu1')(x)
    x = MaxPool2D(pool_size=2)(x)
    x = Conv2D(16, (3, 3), strides=1, padding='valid', name='conv2')(x)
    x = Activation("relu", name='relu2')(x)
    x = Conv2D(32, (3, 3), strides=1, padding='valid', name='conv3')(x)
    x = Activation("relu", name='relu3')(x)
    x = Flatten()(x)
    output = Dense(2,name = "dense")(x)
    output = Activation("relu", name='relu4')(output)
    model = Model([input], [output])
    return model

def gettest_model():
    input = Input(shape=[16, 66, 3])  # change this shape to [None,None,3] to enable arbitraty shape input
    A = Conv2D(10, (3, 3), strides=1, padding='valid', name='conv1')(input)
    B = Activation("relu", name='relu1')(A)
    C = MaxPool2D(pool_size=2)(B)
    x = Conv2D(16, (3, 3), strides=1, padding='valid', name='conv2')(C)
    x = Activation("relu", name='relu2')(x)
    x = Conv2D(32, (3, 3), strides=1, padding='valid', name='conv3')(x)
    K = Activation("relu", name='relu3')(x)


    x = Flatten()(K)
    dense = Dense(2,name = "dense")(x)
    output = Activation("relu", name='relu4')(dense)
    x = Model([input], [output])
    x.load_weights("./model/model12.h5")
    ok = Model([input], [dense])

    for layer in ok.layers:
        print(layer)

    return ok

首先将图像的形状更改为[None, None,3]以启用总裁形状输入,然后使用二维卷积Con2v,及配合激活函数Activation对传入的图像构建神经网络系统并定义模型结构。激活函数在深度学习中扮演着非常重要的角色,它给网络赋予了非线性,从而使得神经网络能够拟合任意复杂的函数。非线性激活函数可以使神经网络随意逼近复杂函数,没有激活函数带来的非线性,多层神经网络和单层无异。

model = getModel()
model.load_weights("./model/model12.h5")

传入图片,进行模型结构的构建,并将构建好的模型返回到model变量中

def finemappingVertical(image):
    resized = cv2.resize(image,(66,16))
    resized = resized.astype(np.float)/255
    res= model.predict(np.array([resized]))[0]
    print("keras_predict",res)
    res  =res*image.shape[1]
    res = res.astype(np.int)
    H,T = res
    H-=3
    #3 79.86
    #4 79.3
    #5 79.5
    #6 78.3


    #T
    #T+1 80.9
    #T+2 81.75
    #T+3 81.75



    if H<0:
        H=0
    T+=2;

    if T>= image.shape[1]-1:
        T= image.shape[1]-1

    image = image[0:35,H:T+2]

    image = cv2.resize(image, (int(136), int(36)))
    return image

使用python的openCV的cv2库对其进行裁剪,最终裁剪为136*36的大小,并返回这个图片。该函数的目的便是裁剪图片,使图片的识别的效率更高

标签:HyperLPR,name,image,系统分析,shape,input,model,车牌,Activation
来源: https://blog.csdn.net/m0_57704837/article/details/120693970

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有