matthewearl / deep-anpr

Using neural networks to build an automatic number plate recognition system
MIT License
1.84k stars 700 forks source link

Apply for 2-line plates? #59

Open tailongnguyen opened 7 years ago

tailongnguyen commented 7 years ago

Hi, I am using your code https://github.com/matthewearl/deep-anpr in my project aiming to recognize not only 1-line plates but also 2-line ones. I have some questions need to be answered and any explanations would be appreciated.

  1. Where does the "-math.log(1./0.99 - 1)" come from? It's the threshold to qualify the windows, isn't it?
  2. Why can you use the weight matrices in training model as the kernels of convolution layers in detect model? I've been trying to find the correlation here.
  3. I modified gen.py to include 2-line plate data and also adjusted the output to be more suitable (9 for max number of characters instead of 7). I trained the model in nearly two days but the loss seemed to stop decreasing after falling to around 200. I know there's must be something wrong here and I suspect that thiis model architecture is not suitable for trying to recognize both of plate types. If anyone has the same problem with me, please give me some pieces of advice.
NightFury13 commented 7 years ago

@tailongnguyen I am not sure about the first query, as for the second and third - while training, the model learns to predict a binary bit (yes/no) saying whether the number plate occurs in the image or not, along with the text prediction. In this way, the detection and recognition capabilities both lie in same set of weights and hence can we used for either task. For the third point, I feel that this architecture won't fit a multi-line detection/recognition setting directly. You could try to incorporate attention modelling in the architecture to make it work.

I'm trying to create similar project. Would you mind sharing your gen.py for creating multi-line number plates? Also, any pointers as to how can one create images with much lesser background-scene-image? Basically, the image being zoomed in to focus majorly on the number plate? I've tried playing with the min_scale and max_scale params under generate_im() in gen.py, is there something else I could look at? My focus here is to generate images only from a 'recognition' perspective, assuming cropped number-plate images are already available.

tailongnguyen commented 7 years ago

@NightFury13 Thanks for replying me. Here is my gen.py, you might need to change the font path and download some fonts that support symbol '-' and '.' (mine is aachenb.ttf). I also sent my model in which I use spatial transformer network (trying to transform the input to output which is easier to regconize), but it still seems not to work well with multi-line plates. I am getting stuck and if you discover anything new please share with me :D gen_vs_model.zip

NightFury13 commented 7 years ago

@tailongnguyen I see a strange thing happening where some images are being rendered without any text in them (example : https://github.com/NightFury13/ANPR/blob/master/max1_min.9_scale_images/00000005_FJ38XR4382_1.png). Any ideas as to why this might be happening? I have changed the min_scale to 0.9 and max_scale to 1.0. All other parameters (like color selection, etc) are the same. I don't see why the entire image text vanished.

mahavird commented 6 years ago

@NightFury13 Hi, I have taken up the ANPR project for the completion of my Udacity NanoDegree.I am able to create a dataset of 10 character license plate images after tinkering around with the code given in the gen.py , , but having some issues while training on the same. Can you share some insights about it ? Do let me know if you need further info.

NightFury13 commented 6 years ago

@Mahavir I haven't looked at the training codes in this repo much. Was more interested in creating real looking NP images. What issues are you facing exactly?

On Wed, 15 Nov 2017, 12:00 p.m. Mahavir Dwivedi, notifications@github.com wrote:

@NightFury13 https://github.com/nightfury13 Hi, I have taken up the ANPR project for the completion of my Udacity NanoDegree.I am able to create a dataset of 10 character license plate images after tinkering around with the code given in the gen.py , https://github.com/matthewearl/deep-anpr/blob/master/gen.py , but having some issues while training on the same. Can you share some insights about it ? Do let me know if you need further info.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/matthewearl/deep-anpr/issues/59#issuecomment-344498633, or mute the thread https://github.com/notifications/unsubscribe-auth/AFem9aXLGjW2okfPzJ1ZHeiBDaI3T5VXks5s2oTtgaJpZM4OlmsL .

mahavird commented 6 years ago

@NightFury13 Glad to hear back from you. Following is the error which I am getting:

Traceback (most recent call last):
  File "train.py", line 266, in <module>
    initial_weights=initial_weights)
  File "train.py", line 239, in train
    do_batch()
  File "train.py", line 224, in do_batch
    do_report()
  File "train.py", line 197, in do_report
    feed_dict={x: test_xs, y_: test_ys})
  File "/home/cs231n/myVE35/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 767, in run
    run_metadata_ptr)
  File "/home/cs231n/myVE35/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 944, in _run
    % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (50, 253) for Tensor 'Placeholder_1:0', which has shape '(?, 361)'

If not the exact error, It would be great if you can point out how to debug the same. It seems it's an architecture error as I have changed the model for 10 characters from 7 characters number plate.

Regards, Mahavir

NightFury13 commented 6 years ago

Yes. It's an issue of incorrect placeholder input values probably due to the change in your NP generation rules. Placeholders expect a specific dimensional input. Try fixing the placeholder input dimensions based on the size of your image (compute feature sizes after each convolution with your 10 character images). That should fix it.

On Wed, 15 Nov 2017, 12:26 p.m. Mahavir Dwivedi, notifications@github.com wrote:

@NightFury13 https://github.com/nightfury13 Glad to hear back from you. Following is the error which I am getting:

Traceback (most recent call last): File "train.py", line 266, in initial_weights=initial_weights) File "train.py", line 239, in train do_batch() File "train.py", line 224, in do_batch do_report() File "train.py", line 197, in do_report feed_dict={x: testxs, y: test_ys}) File "/home/cs231n/myVE35/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 767, in run run_metadata_ptr) File "/home/cs231n/myVE35/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 944, in _run % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape()))) ValueError: Cannot feed value of shape (50, 253) for Tensor 'Placeholder_1:0', which has shape '(?, 361)'

If not the exact error, It would be great if you can point out how to debug the same. It seems it's an architecture error as I have changed the model for 10 characters from 7 characters number plate.

Regards, Mahavir

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/matthewearl/deep-anpr/issues/59#issuecomment-344502972, or mute the thread https://github.com/notifications/unsubscribe-auth/AFem9Uyff6KIqlsxyz8IDw3r-yCx_YeBks5s2os4gaJpZM4OlmsL .