Package: torchok
The toolkit for fast Deep Learning experiments in Computer VisionA day-to-day Computer Vision Engineer backpackTorchOk is based onPyTorchand utilizesPyTorch Lightningfor training pipeline routines.The toolkit consists of:Neural Network models which are proved to be the best not only onPapersWithCodebut in practice. All models are under plug&play interface that easily connects backbones, necks and heads for reuse across tasksOut-of-the-box support of common Computer Vision tasks: classification, segmentation, image representation and detection coming soonCommonly used datasets, image augmentations and transformations (fromAlbumentations)Fast implementations of retrieval metrics (with the help ofFAISSandranx) and lots of other metrics fromtorchmetricsExport models to ONNX and the ability to test the exported model without changing the datasetsAll 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 schedulersTraining, validation and testing configurations are represented by YAML config files and managed byHydraOnly straightforward training techniques are implemented. No whistles and bellsInstallationpipInstallation via pip can be done in two steps:Install PyTorch that meets your hardware requirements viaofficial instructionsInstall TorchOk by runningpip install --upgrade torchokCondaTo remove the previous installation of TorchOk environment, run:condaremove--nametorchok--allTo install TorchOk locally, run:condaenvcreate-fenvironment.ymlThis will create a new conda environmenttorchokwith all dependencies.DockerAnother 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:dockerbuild-ttorchok--build-argSSH_PUBLIC_KEY="<public key>".
dockerrun-d--name<username>_torchok--gpus=all-v<path/to/workdir>:/workdir-p<ssh_port>:22-p<jupyter_port>:8888-p<tensorboard_port>:6006torchokGetting startedThe folderexamples/configscontains YAML config files with some predefined training and inference configurations.TrainFor a training example, we can use the default configurationexamples/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/cifar10folder (341 MB).To train on all available GPU devices (default config):python-mtorchok-cp../examples/configs-cnclassification_cifar10To train on all available CPU cores:python-mtorchok-cp../examples/configs-cnclassification_cifar10trainer.accelerator='cpu'During the training you can access the training and validation logs by starting a local TensorBoard:tensorboard--logdir~/.cache/torchok/logs/cifar10Find learning rateTo automatically find the initial learning rate, we use Pytorch Lightning tuner which algorithm based onCyclical Learning Rates for Training Neural Networksthe article.python-mtorchok-cp../examples/configs-cnclassification_cifar10+entrypoint=find_lrExport to ONNXTODORun ONNX modelFor the ONNX model run, we can use theexamples/configs/onnx_infer.yaml.
But first we need to define the fieldpath_to_onnx.To test ONNX model:pythontest.py-cpexamples/configs-cnonnx_infer+entrypoint=testTo predict ONNX model:pythontest.py-cpexamples/configs-cnonnx_infer+entrypoint=predictRun testspython-munittestdiscover-stests/-p"test_*.py"To be added soon (TODO)TasksMOBY (unsupervised training)InstanceSegmentationTaskDetection modelsYOLOR neck + headDETR neck + headDatasetsImageNetCityscapesLossesPytorch Metric Learning lossesNT-ext (for unsupervised training)