Skip to main content

A lightweight library for pre-processing images for pre-trained keras models

Project description

Keras Image Helper

A lightweight library for pre-processing images for pre-trained keras models

Imagine you have a Keras model. To use it, you need to apply a certain pre-processing function to all the images. Something like that:

from tensorflow.keras.applications.xception import preprocess_input

What if you want to now deploy this model to AWS Lambda? Or deploy your model with TF-Serving? You don't want to use the entire TensorFlow package just for that.

The solution is simple - use keras_image_helper

Usage

For an xception model:

from keras_image_helper import create_preprocessor
preprocessor = create_preprocessor('xception', target_size=(299, 299))

url = 'http://bit.ly/mlbookcamp-pants'
X = preprocessor.from_url(url)

Now you can use X for your model:

preds = model.predict(X)

That's all :tada:

For more examples, check test.ipynb

Currently you can use the following pre-processors:

  • xception
  • resnet50
  • vgg16
  • inception_v3

If something you need is missing, PRs are welcome

Installation

It's available on PyPI, so you can install it with pip:

pip install keras_image_helper

Or with Pipenv:

pipenv install keras_image_helper

You can also install the latest version from this repo:

git clone git@github.com:alexeygrigorev/keras-image-helper.git
python setup.py install

Publishing

Use twine for that:

pip install twine

Generate a wheel:

python setup.py sdist bdist_wheel

Check the packages:

twine check dist/*

Upload the library to test PyPI to verify everything is working:

twine upload --repository-url https://test.pypi.org/legacy/ dist/*

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

keras_image_helper-0.0.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

keras_image_helper-0.0.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file keras_image_helper-0.0.1.tar.gz.

File metadata

  • Download URL: keras_image_helper-0.0.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9

File hashes

Hashes for keras_image_helper-0.0.1.tar.gz
Algorithm Hash digest
SHA256 039575aad983cbe5663e9e347216e839b596b7ec26445de755d7dd4d75c26c2b
MD5 a5c0fa4f11b9802ee3c96b6ff3a08cb8
BLAKE2b-256 e6312b91c001afb4f6b8c6003c31eeab58dd973f2322e042747f38784554bb8e

See more details on using hashes here.

File details

Details for the file keras_image_helper-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: keras_image_helper-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9

File hashes

Hashes for keras_image_helper-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bcea177dd4dfe64101258d20ba4f0e450e6d0ffaba4a35b0ef09651c7006c907
MD5 05e216dc24c0913a283e1242cf7e6122
BLAKE2b-256 b6a36c75d3edcea2c149bd7460f0d9b49ba6bebf5929f9b67f06d79a73f3fb3f

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