Skip to main content

Python implemention of the TensorFlow BodyPix model.

Project description

TensorFlow BodyPix (TF BodyPix)

A Python implementation of body-pix.

(still under development)

CLI

TF_CPP_MIN_LOG_LEVEL=3 \
python -m tf_bodypix \
    image-to-mask \
    --image /path/to/input-image.jpg \
    --output-mask /path/to/output-mask.jpg \
    --threshold=0.75

API

import tensorflow as tf
from tf_bodypix import download_model, load_model, BodyPixModelPaths

bodypix_model = load_model(download_model(
    BodyPixModelPaths.MOBILENET_FLOAT_50_STRIDE_16
))

image = tf.keras.preprocessing.image.load_img(
    '/path/to/input-image.jpg'
)
image_array = tf.keras.preprocessing.image.img_to_array(image)
result = bodypix_model.predict_single(image_array)
mask = result.get_mask(threshold=0.75)
tf.keras.preprocessing.image.save_img(
    '/path/to/output-mask.jpg',
    mask
)

Acknowledgements

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

tf-bodypix-0.0.4.tar.gz (10.6 kB view hashes)

Uploaded Source

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