Skip to content

Implementation of a Spatial Transformer Network (STN) in PyTorch for license plate recognition tasks.

License

Notifications You must be signed in to change notification settings

ApaxPhoenix/License-Plate-STN

Repository files navigation

Spatial Transformer Network (STN) for License Plates

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.

Setup

  1. Clone the repository:

    https://github.com/ApaxPhoenix/License-Plate-STN.git
    cd license-plate-stn
  2. Install dependencies:

    pip install -r requirements.txt
  3. Dataset Preparation:

    • Place your training, target, and validation images in the data/train/, data/target/, and data/val/ directories respectively.
  4. 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] ...
  5. 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.
  6. 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.

Model Architecture

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.

Model Preview

Files Overview

  • access.py: Uses STModel 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.

Dependencies

  • Python 3.x
  • PyTorch
  • torchvision
  • numpy
  • PIL (Pillow)
  • asyncio (for asynchronous operations)

Contributors

@misc{hernandez2024stnlicenseplates,
  title={Spatial Transformer Network (STN) for License Plates},
  author={Hernandez, Andrew},
  year={2024},
  eprint={2406.5130}
}

License

This project is licensed under the AGPL-3.0 License - see the LICENSE file for details.

About

Implementation of a Spatial Transformer Network (STN) in PyTorch for license plate recognition tasks.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages