huanidz / scaled-alpr-unconstrained

(PyTorch) Alpr Unconstrained - Warp Planar Object Detection (WPODNet)
2 stars 0 forks source link

(PyTorch) License Plate Detection and Recognition in Unconstrained Scenarios

PyTorch Logo

PyTorch implementation + scaled of WPOD with simplified code for training + inferencing!


1. Environment installation (venv or conda)

Note: PyTorch 1.9.x is minimum required version
Tested with python 3.8.x
python -m pip install -r requirements.txt

2. Dataset preparation

Please arrange your dataset folder like this
Your_Folder_Path/
├── train
│   ├── images
│   │   ├── train_image_01.png
│   │   ├── train_image_02.png
│   │   ...
│   └── labels
│       ├── train_label_01.txt
│       ├── train_label_02.txt
│       ...
└── eval
    ├── images
    │   ├── eval_image_01.png
    │   ├── eval_image_02.png
    │   ├── ...
    └── labels
        ├── eval_label_01.txt
        ├── eval_label_02.txt
        ├── ...
For each pair of data (image + label), the image is the original image, the label file contains coordinate of the plate with respect to the original image W and H (order is same as original repo)
Note: Currently only support one plate per image. The order of 1-->4 is (x1 - y1: top left, x2 - y2: top right, x3 - y3: bottom right, x4 - y4: bottom left)
# x1, x2, x3, x4, y1, y2, y3, y4
0.497917, 0.677083, 0.670833, 0.489583, 0.734737, 0.747368, 0.844211, 0.831579

3. Training

# Simple 'base' scale training (384x384 input size, ~1.7M parameters, SGD optimizer, 200 epochs, lr = 0.001, batch_size = 16)
python train.py --data path/to/dataset_folder/

# Custom model scale example
python train.py --data path/to/dataset_folder/ --scale small --size 256 --bs 32 --lr 0.0003
Model checkpoints will be saved into checkpoints/ in .pth format

4. Inference

# Example of inferencing with scale 'base', input_size = 384x384, threshold = 0.5.
python inference.py --model_path /path/to/your_model.pth --size 384 --scale base --threshold 0.5

5. ONNX deployment

python export_onnx.py --model_path /path/to/your_model.pth --size 384 --scale small

6. TensorRT Conversion (INT8 Quantization)

python quantize.py --onnx /path/to/model.onnx --engine engine.trt --precision int8 --calib_input /path/to/training_images

TODOs:


@INPROCEEDINGS{silva2018a,
  author={S. M. Silva and C. R. Jung}, 
  booktitle={2018 European Conference on Computer Vision (ECCV)}, 
  title={License Plate Detection and Recognition in Unconstrained Scenarios}, 
  year={2018}, 
  pages={580-596}, 
  doi={10.1007/978-3-030-01258-8_36}, 
  month={Sep},}