Skip to main content

Lightweight package meant to simplify data processing for Deep Learning

Project description

.. |Build-Status| image:: https://travis-ci.com/evoneutron/melon.svg?branch=master :target: https://travis-ci.com/evoneutron/melon

Melon

| Melon is a lightweight package meant to simplify data processing for Deep Learning.

| It removes the need for boilerplate code to pre-process the data prior to (model) training, testing and inference. | It aims at standardizing data serialization and manipulation approaches. | | The default formats align with the requirements by frameworks such as Tensorflow / PyTorch. | The tool also provides various level of customizations depending on the use-case.

Installation

Install and update using pip_:

.. code-block:: text

$ pip install melon

Supported in Python >=3.4.0

.. _pip: https://pip.pypa.io/en/stable/quickstart/

Examples

Images

| With default options_:

.. code-block:: python

from melon import ImageReader

def train():
    source_dir = "resources/images"
    reader = ImageReader(source_dir)
    X, Y = reader.read()
    ...
    with tf.Session() as s:
        s.run(..., feed_dict = {X_placeholder: X, Y_placeholder: Y})

| source_dir directory should contain images that need to be read. See tests/resources/images/sample for a sample directory. In the sample directory there is an optional labels.txt file that is described in Labeling_.


| Since number of images may be too large to fit into memory the tool supports batch-processing. |

.. code-block:: python

from melon import ImageReader

def train():
    source_dir = "resources/images"
    options = { "batch_size": 32 }
    reader = ImageReader(source_dir, options)
    while reader.has_next():
        X, Y = reader.read()
        ...

| This reads images in the batches of 32 until all images are read. If batch_size is not specified then reader.read() will read all images.


.. _Custom options:

| With custom options_:

.. code-block:: python

from melon import ImageReader

def train():
    source_dir = "resources/images"
    options = { "data_format": "channels_last", "normalize": False }
    reader = ImageReader(source_dir, options)
    ...

| This changes format of data to channels-last (each sample will be Height x Width x Channel) and doesn't normalize the data. See options_ for available options.

.. _options:

Options

Images

width
    Width of the output (pixels). default: ``255``

height
    Height of the output (pixels). default: ``255``

batch_size
    Batch size of each read. default: All images in a directory

data_format
    Format of the images data

        | ``channels_first`` - `Channel x Height x Width` (default)
        | ``channels_last`` - `Height x Width x Channel`

label_format
    Format of the labels data

        | ``one_hot`` - as a matrix, with one-hot vector per image (default)
        | ``label`` -  as a vector, with a single label per image


normalize
    Normalize data. default: ``True``

num_threads - number of threads for parallel processing
    default: Number of cores of the machine

.. _Labeling:

Labeling

| In supervised learning each image needs to be mapped to a label. | While the tool supports reading images without labels (e.g. for inference) it also provides a way to label them.


Generating labels file

| To generate labels file use the following command:

.. code-block:: text

$ melon generate
> Source dir:

| After providing source directory the tool will generate labels file in that directory with blank labels. | Final step is to add a label to each row in the generated file. | | For reference see tests/resources/images/sample/labels.txt:

.. code-block:: text

#legend
pedestrian:0
cat:1
parrot:2
car:3
apple tree:4

#map
img275.jpg:1
img324.jpg:2
img551.jpg:3
img928.jpg:1
img999.png:0
img736.png:4

| #legend section is optional but #map section is required to map a label to an image.


Format of the labels

| Label's format can be specified in Custom options_. It defaults to one-hot format.

Roadmap

  • Support for video data

  • Support for textual data

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

melon-0.0.4.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

melon-0.0.4-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file melon-0.0.4.tar.gz.

File metadata

  • Download URL: melon-0.0.4.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.6.5

File hashes

Hashes for melon-0.0.4.tar.gz
Algorithm Hash digest
SHA256 9c97f62de228ede6e2c1a6463af25703d668a0242f6f6fe7b15c8228518526b1
MD5 e6e75bde7f70acc54f02bb074cf13387
BLAKE2b-256 d1255707d2a856b7cebd84284cbd397a6ecc46ada60f6d422a0e7918ac12123d

See more details on using hashes here.

File details

Details for the file melon-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: melon-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.6.5

File hashes

Hashes for melon-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6ed1be9a6b5caf1c6bf11e40a9040dd708409bcf6a4e3a62f710e83893996e53
MD5 336a511de04bb84aa2766d1d07143750
BLAKE2b-256 958537eabbc161e28edbc734b80b1455c6fd28d52f96bfb59887063faf051846

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