This repository contains an implementation of a Spatial Transformer Network (STN) designed specifically for license plate recognition tasks. The STN is a deep learning architecture that facilitates spatial manipulation of images, allowing the model to learn to focus on the most relevant parts of the input images.
access.py
: Enables for the usage of the model.bar.py
: Progress bar implementation (Bar
class) for visualizing training progress.main.py
: Main script for running training and evaluation of the STN model.model.py
: Python file defining the STN model architecture (STModel
class).processing.py
: Utility script for image processing tasks or preprocessing steps.data/
: Directory containing training, target, and validation datasets.README.md
: This file, providing an overview of the project and usage instructions.
-
Clone the repository:
https://github.com/ApaxPhoenix/License-Plate-STN.git cd license-plate-stn
-
Install dependencies:
pip install -r requirements.txt
-
Dataset Preparation:
- Place your training, target, and validation images in the
data/train/
,data/target/
, anddata/val/
directories respectively.
- Place your training, target, and validation images in the
-
Training the Model:
-
Adjust parameters like image size, batch size, and learning rate in
main.py
if necessary. -
Run the training script:
python main.py -mp [MODEL_PATH] --train_path [TRAIN PATH] --target_path [TARGET PATH] ...
-
-
Validation and Evaluation:
- After training, if declared, the model automatically evaluates its performance on the validation dataset.
- Check the validation loss and accuracy metrics printed to the console.
- Make sure the images are supported by pillow.
-
Saving the Model:
- Once satisfied with the training results, the trained model will save itself.
- If another path is provided, use torch supported file extensions.
The STN model (STModel
class) consists of a series of convolutional layers for feature extraction, followed by fully connected layers to predict the transformation parameters. It uses the affine grid generator and sampler to apply the learned transformations to input images.
access.py
: UsesSTModel
and the given trained model for the usage.bar.py
: Implements a progress bar (Bar
class) for visual feedback during training.main.py
: Main script for executing training and evaluation routines.model.py
: Defines the architecture of the STN model (STModel
class).processing.py
: Utility functions for image processing tasks.
- Python 3.x
- PyTorch
- torchvision
- numpy
- PIL (Pillow)
- asyncio (for asynchronous operations)
@misc{hernandez2024stnlicenseplates,
title={Spatial Transformer Network (STN) for License Plates},
author={Hernandez, Andrew},
year={2024},
eprint={2406.5130}
}
This project is licensed under the AGPL-3.0 License - see the LICENSE file for details.