EasyPL - set of wrappers and tools based on PyTorch Lightning to quickly start learning Pytorch models.
This library is a template project for faster deployment of machine learning model training projects based on PyTorch Lightning. If PyTorch Lightning makes learning models easy, then EasyPL makes it super easy.
Quickstart
You can install this library using pip:
pip install easyplib
Note: Sorry for the mismatch between the library name in the pypi index and the documentation. The pypi project name normalization algorithms does not allow you to specify an easypl project name.
If you want install lib for only one task, you can use:
pip install easyplib[task]
where task can be classification, detection, segmentation, gan or you can install all depencies with:
pip install easyplib[all]
Also you can install library manually:
git clone https://github.com/tam2511/EasyPL.git
cd EasyPL
python setup.py install
You can find a description of all functions and API in the documentation.
Examples
You can find all examples on rtd with full training pipelines.
For the library to work correctly, you need to wrap your optimizer and lr scheduler in the appropriate classes, for example:
from easypl.optimizers import WrapperOptimizer
from easypl.lr_schedulers import WrapperScheduler
optimizer = WrapperOptimizer(optim.Adam, lr=1e-4)
lr_scheduler = WrapperScheduler(optim.lr_scheduler.StepLR, step_size=2, gamma=1e-1, interval='epoch')
When using metrics from the torchmetrics library, you can use the TorchMetric wrapper:
from easypl.metrics import TorchMetric
TorchMetric(F1(num_classes=2, average='none'), class_names=['cat', 'dog'])
There are many callbacks available in the EasyPL library. For example, callbacks for image logging, cutmix and test-time augmentation are defined below.
image_logger = ClassificationImageLogger(
phase='train',
max_samples=10,
class_names=['cat', 'dog'],
max_log_classes=2,
dir_path='images',
save_on_disk=True,
)
# Cutmix callback
cutmix = Cutmix(
on_batch=True,
p=1.0,
domen='classification',
)
# Test time augmentation callback
tta = ClassificationImageTestTimeAugmentation(
n=2,
augmentations=[VerticalFlip(p=1.0)],
phase='val'
)
The final part of the training pipeline is the definition of the Learner class and the standard launch of training through the Trainer from the PyTorch Lightning library.
learner = ClassificationLearner(
model=model,
loss=loss_f,
optimizer=optimizer,
lr_scheduler=lr_scheduler,
train_metrics=train_metrics,
val_metrics=val_metrics,
data_keys=['image'],
target_keys=['target'],
multilabel=False
)
trainer = Trainer(
gpus=1,
callbacks=[image_logger, cutmix, tta],
max_epochs=3,
precision=16
)
trainer.fit(learner, train_dataloaders=train_dataloader, val_dataloaders=[val_dataloader])
TODO
- Learner for image detection task.
- Learner for regression task.
- Example learner for GAN training.
- Callbacks for target/sample analytics.
- Finish writing detection part of callbacks.
- Add tests.
Metadata
Release files for easyplib 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| easyplib-1.0.tar.gz | 37.8 kB | Without provenance | Details for easyplib-1.0.tar.gz |
Release files / easyplib-1.0.tar.gz
| Download URL | easyplib-1.0.tar.gz |
|---|---|
| Size | 37.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d4bd7ee8c7628ce599dab6d2816cef14eb4e2c6d58fba34af18a82b01f7d798
|
|
BLAKE2b-256 checksum How to use checksums |
3a74ba58b7fab3a0befa3c9d9f6bf06fc9a646784085bc769c85d56782431427
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Security for easyplib 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.