Streaming over lightweight data transformations

Overview

slide

PyPI version Build Status Codecoverage Codacy Badge License DOI

Description

Data augmentation libarary for Deep Learning, which supports images, segmentation masks, labels and keypoints. Furthermore, SOLT is fast and has OpenCV in its backend. Full auto-generated docs and examples are available here: https://mipt-oulu.github.io/solt/.

Features

  • Support of Images, masks and keypoints for all the transforms (including multiple items at the time)
  • Fast and PyTorch-integrated
  • Convenient and flexible serialization API
  • Excellent documentation
  • Easy to extend
  • 100% Code coverage

Examples

Images: Cats Images + Keypoints: Cats Medical Images + Binary Masks: Brain MRI Medical Images + Multiclass Masks Knee MRI

E.g. the last row is generated using the following transforms stream.

stream = solt.Stream([
    slt.Rotate(angle_range=(-20, 20), p=1, padding='r'),
    slt.Crop((256, 256)),
    solt.SelectiveStream([
        slt.GammaCorrection(gamma_range=0.5, p=1),
        slt.Noise(gain_range=0.1, p=1),
        slt.Blur()    
    ], n=3)
])

img_aug, mask_aug = stream({'image': img, 'mask': mask})

If you want to visualize the results, you need to modify the execution of the transforms:

img_aug, mask_aug = stream({'image': img, 'mask': mask}, return_torch=False).data

Installation

The most recent version is available in pip:

pip install solt

You can fetch the most fresh changes from this repository:

pip install git+https://github.com/MIPT-Oulu/solt

Benchmark

We propose a fair benchmark based on the refactored version of the one proposed by albumentations team, but here, we also convert the results into a PyTorch tensor and do the ImageNet normalization. The following numbers support a realistic and honest comparison between the libraries (number of images per second, the higher - the better):

albumentations
0.4.3
torchvision (Pillow-SIMD backend)
0.5.0
augmentor
0.2.8
solt
0.1.9
HorizontalFlip 2253 2549 2561 3530
VerticalFlip 2380 2557 2572 3740
RotateAny 1479 1389 670 2070
Crop224 2566 1966 1981 4281
Crop128 5467 5738 5720 7186
Crop64 9285 9112 9049 10345
Crop32 11979 10550 10607 12348
Pad300 1642 109 - 2631
VHFlipRotateCrop 1574 1334 616 1889
HFlipCrop 2391 1943 1917 3572

Python and library versions: Python 3.7.0 (default, Oct 9 2018, 10:31:47) [GCC 7.3.0], numpy 1.18.1, pillow-simd 7.0.0.post3, opencv-python 4.2.0.32, scikit-image 0.16.2, scipy 1.4.1.

The code was run on AMD Threadripper 1900. Please find the details about the benchmark here.

How to contribute

Follow the guidelines described here.

Author

Aleksei Tiulpin, Research Unit of Medical Imaging, Physics and Technology, University of Oulu, Finalnd.

How to cite

If you use SOLT and cite it in your research, please, don't hesitate to sent an email to Aleksei Tiulpin. All the papers that use SOLT are listed here.

@misc{solt2019,
  author       = {Aleksei Tiulpin},
  title        = {SOLT: Streaming over Lightweight Transformations},
  month        = jul,
  year         = 2019,
  version      = {v0.1.9},
  doi          = {10.5281/zenodo.3702819},
  url          = {https://doi.org/10.5281/zenodo.3702819}
}
Comments
  • Crashed without clear error message when tranforming multiple images with different shapes

    Crashed without clear error message when tranforming multiple images with different shapes

    Code to reproduce:

    import solt
    import solt.transforms as slt
    import numpy as np
    
    
    if __name__ == "__main__":
        trf = solt.Stream([slt.Resize(resize_to=(50, 50)),
                           slt.Flip()])
        img1 = np.ones((100, 100, 3), dtype=np.int32)
        img2 = np.ones((110, 110, 3), dtype=np.int32)
        trf_img = trf({'images': (img1, img2)})
        print('Done')
    

    Adding a resize transformation at the beginning doesn't help. A clear error message is needed for this case.

    opened by hoanghng 4
  • NameError: name 'ktps' is not defined

    NameError: name 'ktps' is not defined

    While testing one of the notebook algorithm, this error occured: kpts = None for annotation_fname in glob.glob(os.path.join('Data', 'helen_annotations', '*.txt')): with open(annotation_fname) as f: if f.readline()[:-1] == fname.split('.')[0]: ktps = [] for l in f: tmp = l.split() ktps.append([float(tmp[0]), float(tmp[2])]) break kpts = np.array(ktps)

    Specific Error:

    NameError Traceback (most recent call last) in 8 ktps.append([float(tmp[0]), float(tmp[2])]) 9 break ---> 10 kpts = np.array(ktps)

    NameError: name 'ktps' is not defined

    opened by tobimichigan 3
  • Use pytorch for 3D+ data

    Use pytorch for 3D+ data

    Proof of concept.

    • Switched to pytorch for 3D+ in Flip, Crop and Pad
    • Flip now accepts multiple axes, but not axis=-1. Also, the axis order has been switched from opencv to numpy
    • Minor cleanup to the tests
    opened by soupault 2
  • nd follow-up

    nd follow-up

    • Removed height and width concepts where possible
    • Switched from shape checking decorator to function
    • Added shape validation also for masks and keypoints
    • Splitted utils into checks and serial
    opened by soupault 2
  • Bump opencv-python-headless from 4.1.2.30 to 4.2.0.32 in /ci

    Bump opencv-python-headless from 4.1.2.30 to 4.2.0.32 in /ci

    Bumps opencv-python-headless from 4.1.2.30 to 4.2.0.32.

    Release notes

    Sourced from opencv-python-headless's releases.

    4.2.0.32

    OpenCV version 4.2.0.

    Changes:

    • macOS environment updated from xcode8.3 to xcode 9.4
    • macOS uses now Qt 5 instead of Qt 4
    • Nasm version updated to Docker containers
    • multibuild updated

    Fixes:

    • don't use deprecated brew tap-pin, instead refer to the full package name when installing #267
    • replace get_config_var() with get_config_vars() in setup.py #274
    • add workaround for DLL errors in Windows Server #264
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Fix the documentation bug

    Fix the documentation bug

    https://github.com/MIPT-Oulu/solt/blob/485bfb0d471134f75e09d06aa5e9ce4b57c0e13c/solt/transforms/_transforms.py#L1018 tells something about noise. Should talk about the intensities instead.

    opened by lext 1
  • Compatibility issues with latest pytorch

    Compatibility issues with latest pytorch

    Works fine with 1.1, but not 1.5. Traceback:

        as_dict=as_dict, scale_keypoints=scale_keypoints, normalize=normalize, mean=mean, std=std,
      File ".../site-packages/solt/core/_data.py", line 273, in to_torch
        img.sub_(mean)
    RuntimeError: output with backend CPU and dtype Byte doesn't match the desired backend CPU and dtype Float
    Process finished with exit code 1
    
    opened by soupault 1
  • Can't run unit tests locally on MacOS

    Can't run unit tests locally on MacOS

    🐛 Bug

    It is not possible to run unit tests locally on MacOS X (10.12).

    To Reproduce

    Steps to reproduce the behavior:

    1. Create a conda environment and install all of the packages as suggested here.

    2. Run the following code: pytest tests

    3. The unit tests fail and generate an error:

    ImportError while importing test module '/Users/melekhi1/projects/solt/tests/test_data_core.py'.
    Hint: make sure your test modules/packages have valid Python names.
    Traceback:
    tests/test_data_core.py:4: in <module>
        import cv2
    ../../anaconda2/envs/solt_test_env/lib/python3.8/site-packages/cv2/__init__.py:3: in <module>
        from .cv2 import *
    E   ImportError: dlopen(/Users/melekhi1/anaconda2/envs/solt_test_env/lib/python3.8/site-packages/cv2/cv2.cpython-38-darwin.so, 2): Symbol not found: _inflateValidate
    E     Referenced from: /Users/melekhi1/anaconda2/envs/solt_test_env/lib/python3.8/site-packages/cv2/.dylibs/libpng16.16.dylib (which was built for Mac OS X 10.13)
    E     Expected in: /usr/lib/libz.1.dylib
    E    in /Users/melekhi1/anaconda2/envs/solt_test_env/lib/python3.8/site-packages/cv2/.dylibs/libpng16.16.dylib
    

    Expected behavior

    The unit tests should pass

    =============================== test session starts ================================
    platform darwin -- Python 3.8.2, pytest-3.6.4, py-1.8.1, pluggy-0.7.1
    rootdir: /Users/melekhi1/projects/solt, inifile:
    plugins: pep8-1.0.6, flake8-1.0.2, cov-2.6.0
    collected 701 items
    
    tests/test_base_transforms.py .............................................. [  6%]
    ............................................................................ [ 17%]
    .....                                                                        [ 18%]
    tests/test_data_core.py .................................................... [ 25%]
    ............................................................................ [ 36%]
    ............................................................................ [ 47%]
    ..................................................................           [ 56%]
    tests/test_transforms.py ................................................... [ 63%]
    ............................................................................ [ 74%]
    ............................................................................ [ 85%]
    ............................................................................ [ 96%]
    .........                                                                    [ 97%]
    tests/test_utils.py ................                                         [100%]
    
    ============================ 701 passed in 6.79 seconds ============================
    

    Suggestions

    It seems the bug is related to the latest version of opencv-python-headless (4.2.0.32) package. Apparently, its previous version, 4.1.2.30, could solve the issue at least for this particular platform (MacOS 10.12). It would be great to test this solution on more recent MacOS.

    opened by imelekhov 1
  • Incorrect serialization of a cropping transform

    Incorrect serialization of a cropping transform

    The attribute crop_size needs to be renamed into crop_to to match the constructor. Otherwise, the serialization does not work well.

    https://github.com/MIPT-Oulu/solt/blob/770e397884bcafe80a11723c229e275c1c1f8b5a/solt/transforms/_transforms.py#L715

    bug 
    opened by lext 1
  • Fair benchmark with the other libraries

    Fair benchmark with the other libraries

    the augbench package needs further development and its results need to be reported in the README.

    the benchmark needs to cover random transformations rather than the static ones. It is important to make comparison for three cases: image, image mask, and image+10 masks (instance segmentation task).

    opened by lext 1
  • Brightness needs to support percentages of the mean intensity

    Brightness needs to support percentages of the mean intensity

    The use case for this is that for some images it might be better to rely on their mean intensity and increase their intensity by n% of the mean value.

    enhancement 
    opened by lext 0
  • Allow to randomly select random number of augmentations in Selective stream

    Allow to randomly select random number of augmentations in Selective stream

    Currently, selective stream takes a parameter that tells how many transforms to select from the list of transformations. I was recently suggested to make it a range and allow to sample random number of augmentations out of this range.

    feature request 
    opened by lext 0
Releases(v0.1.9)
  • v0.1.9(Mar 10, 2020)

    • [x] SOLT is now PyTorch Native
    • [x] All the transform subtract the mean and std by default
    • [x] Implemented a proper serialization and deserialization
    • [x] Allowed to use dict instead of a data container
    • [x] Introduced shorter transform names
    • [x] Implemented a fair benchmark to compare with other libraries
    • [x] Fixed a bug of JPEGCompression (@tiulpin )
    • [x] Added IntensityRemappping transform (@soupault )

    This release is not backward comparible

    Source code(tar.gz)
    Source code(zip)
  • v0.1.8(Jul 26, 2019)

  • v0.1.7(Jul 6, 2019)

    This release has some tests-related features and also adds two new transforms.

    Detailed description:

    • [x] Improved and parametrized many more testes
    • [x] Added CutOut data augmentation
    • [x] Added KeypointsJitter class that allows to apply random displacements to keypoints
    Source code(tar.gz)
    Source code(zip)
  • v0.1.6(May 25, 2019)

  • v0.1.5(Feb 15, 2019)

  • v0.1(Nov 13, 2018)

  • v0.0.6(Sep 21, 2018)

Owner
Research Unit of Medical Imaging, Physics and Technology
Research Unit of Medical Imaging, Physics and Technology
Deep Learning Algorithms for Hedging with Frictions

Deep Learning Algorithms for Hedging with Frictions This repository contains the Forward-Backward Stochastic Differential Equation (FBSDE) solver and

Xiaofei Shi 3 Dec 22, 2022
code for paper "Not All Unlabeled Data are Equal: Learning to Weight Data in Semi-supervised Learning" by Zhongzheng Ren*, Raymond A. Yeh*, Alexander G. Schwing.

Not All Unlabeled Data are Equal: Learning to Weight Data in Semi-supervised Learning Overview This code is for paper: Not All Unlabeled Data are Equa

Jason Ren 22 Nov 23, 2022
Simple (but Strong) Baselines for POMDPs

Recurrent Model-Free RL is a Strong Baseline for Many POMDPs Welcome to the POMDP world! This repo provides some simple baselines for POMDPs, specific

Tianwei V. Ni 172 Dec 29, 2022
Python implementation of cover trees, near-drop-in replacement for scipy.spatial.kdtree

This is a Python implementation of cover trees, a data structure for finding nearest neighbors in a general metric space (e.g., a 3D box with periodic

Patrick Varilly 28 Nov 25, 2022
High-quality implementations of standard and SOTA methods on a variety of tasks.

Uncertainty Baselines The goal of Uncertainty Baselines is to provide a template for researchers to build on. The baselines can be a starting point fo

Google 1.1k Dec 30, 2022
Array Camera Ptychography

Array Camera Ptychography This repository provides the code for the following papers: Schulz, Timothy J., David J. Brady, and Chengyu Wang. "Photon-li

Brady lab in Optical Sciences 1 Nov 15, 2021
Source code for 2021 ICCV paper "In-the-Wild Single Camera 3D Reconstruction Through Moving Water Surfaces"

In-the-Wild Single Camera 3D Reconstruction Through Moving Water Surfaces This is the PyTorch implementation for 2021 ICCV paper "In-the-Wild Single C

27 Dec 06, 2022
Topic Modelling for Humans

gensim – Topic Modelling in Python Gensim is a Python library for topic modelling, document indexing and similarity retrieval with large corpora. Targ

RARE Technologies 13.8k Jan 03, 2023
Pytorch-diffusion - A basic PyTorch implementation of 'Denoising Diffusion Probabilistic Models'

PyTorch implementation of 'Denoising Diffusion Probabilistic Models' This reposi

Arthur Juliani 76 Jan 07, 2023
Dense matching library based on PyTorch

Dense Matching A general dense matching library based on PyTorch. For any questions, issues or recommendations, please contact Prune at

Prune Truong 399 Dec 28, 2022
Deep Multi-Magnification Network for multi-class tissue segmentation of whole slide images

Deep Multi-Magnification Network This repository provides training and inference codes for Deep Multi-Magnification Network published here. Deep Multi

Computational Pathology 12 Aug 06, 2022
Implementation of our paper 'RESA: Recurrent Feature-Shift Aggregator for Lane Detection' in AAAI2021.

RESA PyTorch implementation of the paper "RESA: Recurrent Feature-Shift Aggregator for Lane Detection". Our paper has been accepted by AAAI2021. Intro

137 Jan 02, 2023
CARLA: A Python Library to Benchmark Algorithmic Recourse and Counterfactual Explanation Algorithms

CARLA - Counterfactual And Recourse Library CARLA is a python library to benchmark counterfactual explanation and recourse models. It comes out-of-the

Carla Recourse 200 Dec 28, 2022
Pytorch code for paper "Image Compressed Sensing Using Non-local Neural Network" TMM 2021.

NL-CSNet-Pytorch Pytorch code for paper "Image Compressed Sensing Using Non-local Neural Network" TMM 2021. Note: this repo only shows the strategy of

WenxueCui 7 Nov 07, 2022
AI drive app that can help user become beautiful.

爱美丽 Beauty 简体中文 Features Beauty is an AI drive app that can help user become beautiful. it contain those functions: face score cheek face beauty repor

Starved Midnight 1 Jan 30, 2022
This repository contains code demonstrating the methods outlined in Path Signature Area-Based Causal Discovery in Coupled Time Series presented at Causal Analysis Workshop 2021.

signed-area-causal-inference This repository contains code demonstrating the methods outlined in Path Signature Area-Based Causal Discovery in Coupled

Will Glad 1 Mar 11, 2022
PyTorch Implementation of NCSOFT's FastPitchFormant: Source-filter based Decomposed Modeling for Speech Synthesis

FastPitchFormant - PyTorch Implementation PyTorch Implementation of FastPitchFormant: Source-filter based Decomposed Modeling for Speech Synthesis. Qu

Keon Lee 63 Jan 02, 2023
Multi Agent Path Finding Algorithms

MATP-solver Simulator collision check path step random initial states or given states Traditional method Seperate A* algorithem Confict-based Search S

30 Dec 12, 2022
Code for the ICCV 2021 paper "Pixel Difference Networks for Efficient Edge Detection" (Oral).

Microsoft365_devicePhish Abusing Microsoft 365 OAuth Authorization Flow for Phishing Attack This is a simple proof-of-concept script that allows an at

Alex 236 Dec 21, 2022
[NeurIPS 2021] "G-PATE: Scalable Differentially Private Data Generator via Private Aggregation of Teacher Discriminators"

G-PATE This is the official code base for our NeurIPS 2021 paper: "G-PATE: Scalable Differentially Private Data Generator via Private Aggregation of T

AI Secure 14 Oct 12, 2022