Skip to main content

The toolkit for fast Deep Learning experiments in Computer Vision

Project description

TorchOk

The toolkit for fast Deep Learning experiments in Computer Vision

A day-to-day Computer Vision Engineer backpack

Build Status

TorchOk is based on PyTorch and utilizes PyTorch Lightning for training pipeline routines.

The toolkit consists of:

  • Neural Network models which are proved to be the best not only on PapersWithCode but in practice. All models are under plug&play interface that easily connects backbones, necks and heads for reuse across tasks
  • Out-of-the-box support of common Computer Vision tasks: classification, segmentation, image representation and detection coming soon
  • Commonly used datasets, image augmentations and transformations (from Albumentations)
  • Fast implementations of retrieval metrics (with the help of FAISS and ranx) and lots of other metrics from torchmetrics
  • Export models to ONNX and the ability to test the exported model without changing the datasets
  • All components can be customized by inheriting the unified interfaces: Lightning's training loop, tasks, models, datasets, augmentations and transformations, metrics, loss functions, optimizers and LR schedulers
  • Training, validation and testing configurations are represented by YAML config files and managed by Hydra
  • Only straightforward training techniques are implemented. No whistles and bells

Installation

pip

Installation via pip can be done in two steps:

  1. Install PyTorch that meets your hardware requirements via official instructions
  2. Install TorchOk by running pip install --upgrade torchok

Conda

To remove the previous installation of TorchOk environment, run:

conda remove --name torchok --all

To install TorchOk locally, run:

conda env create -f environment.yml

This will create a new conda environment torchok with all dependencies.

Docker

Another way to install TorchOk is through Docker. The built image supports SSH access, Jupyter Lab and Tensorboard ports exposing. If you don't need any of this, just omit the corresponding arguments. Build the image and run the container:

docker build -t torchok --build-arg SSH_PUBLIC_KEY="<public key>" .
docker run -d --name <username>_torchok --gpus=all -v <path/to/workdir>:/workdir -p <ssh_port>:22 -p <jupyter_port>:8888 -p <tensorboard_port>:6006 torchok

Getting started

The folder examples/configs contains YAML config files with some predefined training and inference configurations.

Train

For a training example, we can use the default configuration examples/configs/classification_cifar10.yml, where the CIFAR-10 dataset and the classification task are specified. The CIFAR-10 dataset will be automatically downloaded into your ~/.cache/torchok/data/cifar10 folder (341 MB).

To train on all available GPU devices (default config):

python -m torchok -cp ../examples/configs -cn classification_cifar10

To train on all available CPU cores:

python -m torchok -cp ../examples/configs -cn classification_cifar10 trainer.accelerator='cpu'

During the training you can access the training and validation logs by starting a local TensorBoard:

tensorboard --logdir ~/.cache/torchok/logs/cifar10

Find learning rate

To automatically find the initial learning rate, we use Pytorch Lightning tuner which algorithm based on Cyclical Learning Rates for Training Neural Networks the article.

python -m torchok -cp ../examples/configs -cn classification_cifar10 +entrypoint=find_lr

Export to ONNX

TODO

Run ONNX model

For the ONNX model run, we can use the examples/configs/onnx_infer.yaml. But first we need to define the field path_to_onnx.

To test ONNX model:

python test.py -cp examples/configs -cn onnx_infer +entrypoint=test

To predict ONNX model:

python test.py -cp examples/configs -cn onnx_infer +entrypoint=predict

Run tests

python -m unittest discover -s tests/ -p "test_*.py"

To be added soon (TODO)

Tasks

  • MOBY (unsupervised training)
  • InstanceSegmentationTask

Detection models

  • YOLOR neck + head
  • DETR neck + head

Datasets

  • ImageNet
  • Cityscapes

Losses

  • Pytorch Metric Learning losses
  • NT-ext (for unsupervised training)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torchok-0.4.12.tar.gz (119.8 kB view details)

Uploaded Source

Built Distribution

torchok-0.4.12-py3-none-any.whl (166.1 kB view details)

Uploaded Python 3

File details

Details for the file torchok-0.4.12.tar.gz.

File metadata

  • Download URL: torchok-0.4.12.tar.gz
  • Upload date:
  • Size: 119.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for torchok-0.4.12.tar.gz
Algorithm Hash digest
SHA256 66dd0b26f55bf5e5540f73b9875f4b0c168d02718c047e131257b8f5f688198a
MD5 627b60b98b20118449f25e505a14351e
BLAKE2b-256 d550f635832b448f0fb5094b4848c50adde4db37b752ddedaafb89ea70e0e383

See more details on using hashes here.

File details

Details for the file torchok-0.4.12-py3-none-any.whl.

File metadata

  • Download URL: torchok-0.4.12-py3-none-any.whl
  • Upload date:
  • Size: 166.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for torchok-0.4.12-py3-none-any.whl
Algorithm Hash digest
SHA256 ae5baea9cb4fd7f212d79c96aa6657e64f9ba31ce403cda635c23a6739283b02
MD5 a6ff0a00c3a96121882807e807dd57b2
BLAKE2b-256 ceb41b20321d59d99234439c0a86982f20bc8ac74109bc8a81a79eb92e530f50

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page