Git Product home page Git Product logo

plate_recognition-lprnet's Introduction

Plate_Recognition-LPRnet

this code is based on the paper : LPRNet: License Plate Recognition via Deep Neural Networks https://arxiv.org/pdf/1806.10447.pdf

it is a kind of light network for plate recognition.

it uses CNN + CTC loss to recognise the plate without segmentation.

Step 1: set the default value

In the file LPRtf3.py:

num_epochs = 300

INITIAL_LEARNING_RATE = 1e-3

DECAY_STEPS = 2000

LEARNING_RATE_DECAY_FACTOR = 0.9 # The learning rate decay factor

MOMENTUM = 0.9

REPORT_STEPS = 5000

#the num of training data

BATCH_SIZE = 50

TRAIN_SIZE = 7368

BATCHES = TRAIN_SIZE//BATCH_SIZE

test_num = 3

ti = 'train' #the location of training data

vi = 'valid' #the location of validation data

img_size = [94, 24]

tl = None

vl = None

num_channels = 3

label_len = 7 #the length of plate character

Step 2: start training

running

$python3 LPRtf3.py

and then the screen will show:

'train or test:'

then:

input 'train' for training

input 'test' for testing

if you want to train your own data,you just need to rename your plate file as "province(convert the Chinese character to the coresponding code according to 'dict' in the LPRnet.py)_the numbers and alphabet of the plate", the examples is in the folder 'train'.

plate_recognition-lprnet's People

Contributors

lyl8213 avatar tp-nan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plate_recognition-lprnet's Issues

shape inconsistency issue between input data and kernal

I saw in your code when image processing,you made input shape to NWHC format:
'''python
images = np.transpose(images, axes=[0, 2, 1, 3])
'''
but in network building ,the default kernal shape is NHWC format.

so I'm not quite sure if it's my understanding issue or it's a bug in your code.

UnicodeEncodeError

Epoch....... 33
Epoch 34/300, steps = 4998, train_cost = 0.000, train_ler = 0.000, val_cost = 1.423, val_ler = 0.023, time = 2.851s, learning_rate = 0.0008099999977275729
Epoch....... 34
time:0.9731936454772949
T/F: original(length) <-------> detectcted(length)
True Traceback (most recent call last):
File "LPRtf3.py", line 454, in
train(a)
File "LPRtf3.py", line 419, in train
c, steps = do_batch(train_gen,val_gen)
File "LPRtf3.py", line 406, in do_batch
do_report(val_gen,test_num)
File "LPRtf3.py", line 374, in do_report
report_accuracy(dd, test_targets)
File "LPRtf3.py", line 359, in report_accuracy
print(hit, number, "(", len(number), ") <-------> ", detect_number, "(", len(detect_number), ")")
UnicodeEncodeError: 'ascii' codec can't encode character '\u6d59' in position 2: ordinal not in range(128)

how to train

请问 怎么训练自己的样本,我想训练自己的样本,但是不知道训练样本标签格式

How to test single lpr plate .

Hi can you please write steps for training single lpr plate . your code seems to be for batch size 50.
I mean if i create a folder named test and put only one image . it should be able to give output.

为什么训练到30epoch左右就出现train_cost为0,而且val_cost没有减少?而且使用model8.24best里的模型进行测试时都是出现长度不一致,得不到测试结果?

训练的现象如下:
Epoch 26/300, steps = 3822, train_cost = 0.000, logits_size = (24, 50, 67), val_cost = 12.472, val_ler = 0.146, time = 1.824s, learning_rate = 0.0009000000427477062 Epoch....... 26 Epoch 27/300, steps = 3969, train_cost = 0.000, logits_size = (24, 50, 67), val_cost = 13.910, val_ler = 0.148, time = 1.781s, learning_rate = 0.0009000000427477062 Epoch....... 27 Epoch 28/300, steps = 4116, train_cost = 0.000, logits_size = (24, 50, 67), val_cost = 13.581, val_ler = 0.156, time = 1.778s, learning_rate = 0.0008099999977275729 Epoch....... 28 Epoch 29/300, steps = 4263, train_cost = 0.000, logits_size = (24, 50, 67), val_cost = 13.747, val_ler = 0.156, time = 1.954s, learning_rate = 0.0008099999977275729

测试的现象如下:
len(original_list) 50 len(detected_list) 1 test and detect length desn't match time:0.2623302936553955 len(original_list) 50 len(detected_list) 1 test and detect length desn't match time:0.27623462677001953 len(original_list) 50 len(detected_list) 1 test and detect length desn't match time:0.2702765464782715 len(original_list) 50 len(detected_list) 1 test and detect length desn't match time:0.27227091789245605 len(original_list) 50 len(detected_list) 1 test and detect length desn't match

Question: Output layer for graph freeze?

Hi, before all amazing work with Plate Recognition - LPRnet implementation.

I have been trying to freeze the graph but I can't figure out the output layer to use on freeze_graph.

This is th freezing code I'm trying to use.

python3 ../tensorflow/tensorflow/python/tools/freeze_graph.py \
		--input_graph=input.pb \
		--input_binary=false \
		--input_checkpoint=lprtf3.ckpt \
		--output_graph=output.pb \
		--output_node_name=??

The input.pb includes the result of the saves of

tf.train.write_graph(session.graph.as_graph_def(), MODEL_FOLDER, "input.pb")

Any ideas on what to use on output_node_name ??

Prediction script

Do you have a single prediction script that goes by single image
This kind of function will be extremely helpful to your project

Train on different type of licence plate?

Hi
Thank you for sharing your code, is it possible to use your code to train a different type of licence plates?

Here is a picture of the kind of number plate i want to train your network on :

1

transfer learning

is it possible to use checkpoints in your code for tranfser learning?

advantage of division and reduce_mean and square part layers

Hi @lyl8213
why we use this part of the code? what's the advantage of this part?

    cx = mean(sqrt(x))
    x = Lambda(lambda x: x[0]/x[1])([x,cx]) # division

    x1 = AveragePooling2D(pool_size=[4,1],strides=[4,1],padding='same')(inputs)
    cx1 = mean(sqrt(x1))
    x1 = Lambda(lambda x: x[0]/x[1])([x1,cx1]) # division

    x2 = AveragePooling2D(pool_size=[4,1],strides=[4,1],padding='same')(x2)
    cx2 = mean(sqrt(x2))
    x2 = Lambda(lambda x: x[0]/x[1])([x2,cx2]) # division

    x3 = AveragePooling2D(pool_size=[2,1],strides=[2,1],padding='same')(x3)
    cx3 = mean(sqrt(x3))
    x3 = Lambda(lambda x: x[0]/x[1])([x3,cx3]) # division

    x = concatenate([x,x1,x2,x3], axis=3)

how to train/test

train or test:test

UnboundLocalError Traceback (most recent call last)
in
444 if name == "main":
445 a = input('train or test:')
--> 446 train(a)

in train(a)
305 img_size=img_size,
306 num_channels=num_channels,
--> 307 label_len=label_len)
308
309 val_gen = TextImageGenerator(img_dir=vi,

in init(self, img_dir, label_file, batch_size, img_size, num_channels, label_len)
65 self.labels = []
66
---> 67 self.init()
68
69 def init(self):

i got this error every time i try to train or test
in init(self)
77 #else:
78 # label = dict[filename[:3]] + filename[4:10]
---> 79 label = encode_label(label)
80 self.labels.append(label)
81 self._num_examples += 1

UnboundLocalError: local variable 'label' referenced before assignment

The width and Height is misplaced

img_size = [94, 24]
inputs = tf.placeholder(tf.float32, shape=(b, img_size[0], img_size[1], num_channels))
however, the shape order should be [batchsize, height, width, channel]

Full dataset

In the paper, it is mentioned that "In total, the dataset contains 11696 cropped license plate images, which are split as 9:1 into training and validation subsets respectively".
However, the number of images in the train folder is only 752.
Can you please share the full dataset?

Error after train

If I put python LPRtf3.py and testthis is the output:

len(original_list) 50 len(detected_list) 1  test and detect length desn't match
time:0.7172296047210693
len(original_list) 50 len(detected_list) 1  test and detect length desn't match
time:0.7143244743347168
len(original_list) 50 len(detected_list) 1  test and detect length desn't match

What is it wrong?

可提供数据支持

我可提供蓝色绿色黄色车牌数据以及相关代码,准确率可达95%+。q:1041357701

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.