Skip to content

saaresearch/TripletRecognitionSystem

Repository files navigation

TripletNet recognition system

img_2.png



Open In Colab

Documentation

See the Wiki for documentation on training, testing and deployment.

Install
🛠 Install 🛠
git clone 
  1. Install Python >=3.8.5 and <3.9
  2. Create virtual environment:
python -m venv .env
  1. Activate environment

    • on windows: .env\Scripts\activate
    • on linux/mac: source .env/bin/activate
  2. Install dependencies:

pip install -r requirements.txt -f https://download.pytorch.org/whl/torch_stable.html

Description of the system

Our system allows you to train machine learning models on small datasets, and also allows you to get a ready-made quantized model for use on mobile devices

The project contains the following utilities:

  • Preprocessing (pdd/data_utils.py)
  • Utils for create dataloaders
    • Split datasetutils (pdd/train_test_split.py)
    • Prepare dataloaders utils(train.py and pdd/data_utils.py )
  • Utils for training :
    • Training Triplet extactor model with KNN classifier (train.py, pdd/trainer.py, pdd/model.py, pdd/tripletttorch.py)
    • Training MLP classifier for extractor model (classifier_train.py)
  • Utils for test model (script.py, perceptron_script.py,confusion_matrix.py )
  • Utils for quantization
    • Static quantization available only for MobileNetV2 model and training only on CPU (all files with prefix quant)
    • Dynamic quantization (dynamic_quantization.py)

Image classification model

For training and using the model, all methods of transferring training, Siamese networks with triplet loss, and a metric based on KNN was used to check the quality of training. Each twin of the triplet siamese network is a complete copy of its neighbor, so after the training, we can take any of the twins that will be the feature extractor. Features extracted using the pretrained network are feed to the input of the classifier to get the class prediction at the output.

Scheme A show Simese network with three twins and the triplet loss function. Scheme B show one of the twins used as a feature extractor followed by a MLP as a Classifier

Usage example

The resulting model can be used for web and mobile applications:

Telegram bot:

Link:

Android Application

Link:

Custom Dataset and model training

Instruction for dataset loading and git demo chek in Open In Colab

Citation

@article{
  title={CLASSIFICATION OF FEATURES ON FLOWER SURFACES USING COMPRESSED MACHINE LEARNING MODELS},
  author={SMETANIN A.A., PERSHUTKIN A.E., DUKHANOV A.V.},
  journal={Top technologies, № 6 -p. 29-34   },
  year={2022}
}

About

No description, website, or topics provided.

Resources

License

Stars

4 stars

Watchers

2 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages