A python library to augment the images dataset aimed for a ML classification system
Project description
Table of Contents
Scope
The scope of this library is to augment the dataset for an image classification ML system.
Setup
Versions
The library is compatible with python 3.7
.
Virtualenv
We suggest to isolate your installation via python virtualenv:
python3 -m venv .imgaug
...
source .imgaug/bin/activate
Installation
Update pip
package manager:
pip install pip --upgrade
...
pip install -r requirements.txt
Tests
The library is covered, by fast, isolated unit and doc testing (the latter to grant reliable documentation):
python -m unittest discover -s imgaug -p '*'
...................
----------------------------------------------------------------------
Ran 19 tests in 0.898s
OK
Dataset
The system is aimed to work with images of different sizes, saved as PNG or JPG files (supporting RGBA conversion).
Labeller
The target label is extracted directly by inspecting the image name and trying to extract meaningful information (customisable).
lbl = Labeller()
lbl('resources/1096023906001-c-suit-veletta-albino.jpg')
'1096023906001'
Normalizer
The images are normalized by:
- resizing them to the specified max size (default to 256 pixels)
- optionally applying a squared, transparent canvas and centering the image on it, thus avoiding any deformation
norm = Normalizer(size=128, canvas=True)
img = norm('resources/bag.png')
img.shape
(128, 128, 4)
Augmenter
The number of images is augmented by three orders of magnitude (depending on the cutoff attribute) by applying different transformations to the original one.
Transformations are applied by using generators, thus saving memory consumption.
aug = Augmenter()
aug.count
1000
Persister
Images are persisted upon normalization and augmentation, by passing a BytesIO
object to the specified action function. The persister can be iterated upon function return value and label.
def persist(name, data):
filename = f'temp/{name}'
with open(filename, 'wb') as f:
f.write(data.getvalue())
return filename
pers = Persister('resources/skirt.jpg', action=perist)
for label, filename in pers:
print(label, filename)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for image_augmenter-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84592dfc6e4bac39795ffe2bb10519ab0856cba6fa66c5ccd01cca26976e0797 |
|
MD5 | d772568bdf08fdbf9c34cd04b4774e88 |
|
BLAKE2b-256 | 703b2bbb775f0071b5d504c8eadc73c9a0bd4eef11638c31eeac1ed5ed3127c7 |