unilm icon indicating copy to clipboard operation
unilm copied to clipboard

TrOCR small usage for license plate ocr

Open SwEngine opened this issue 9 months ago • 5 comments

Hi, I want to train trocr-small-printed for license plate ocr for my school work. However, when I use trocr model from huggingface, the decoded outputs are garbage English words and not meaningful for license plates. How should I define VisionEncoderDecoderModel and TrOCRProcessor? How should I change vocabulary etc? And what type of encoder-decoder should I use? Thanks in advance!

SwEngine avatar May 16 '24 05:05 SwEngine

For license plate ocr, I would recommend using base-printed and colab for training.

https://github.com/NielsRogge/Transformers-Tutorials/blob/master/TrOCR/Fine_tune_TrOCR_on_IAM_Handwriting_Database_using_native_PyTorch.ipynb

rohit5895 avatar May 17 '24 20:05 rohit5895

I am already using the notebook of NielsRogge, however outputs are not license plate characters. Decoded outputs are english words and do not match with plate characters. In addition, I am also using base-printed pretrained model. Vocabulary or something is wrong.

SwEngine avatar May 21 '24 04:05 SwEngine

Can you share your code?

rohit5895 avatar May 22 '24 18:05 rohit5895

When I use trocr-small-printed as processor and trocr-small-printed as model, outputs are sequence of characters as expected. However, when I use trocr-base-printed as processor and trocr-base-printed as model, outputs are not sequence of characters, outputs come as sequence of words. What can be the problem? Code is same with NielsRogge's code. @rohit5895 @NielsRogge

Example: Using trocr-small-printed: Label: 331203_ASD Predict: 331203_ASD Using trocr-base-printed: Label: 331203_ASD Predict: memory Strengthig French previousinterest build

Note: I am printing "pred_str[0]" in the "compute_cer" function.

SwEngine avatar Jun 07 '24 07:06 SwEngine

Any idea?

SwEngine avatar Jun 16 '24 05:06 SwEngine