Skip to main content

A wrapper that contains quick functions to load and process data with Googles TF Hub v2 fast arbitrary image style transfer model

Project description

TF Hub Wrapper

This package contains functions to properly load and process images for input to Google's TensorFlow Hub v2 model for fast arbitrary image style transfer and obtain a style-transferred output image.

'Example Output'

Usage:

First, install the package with pip:

pip install tfhub-styletransfer-wrapper

Then import the package:

import tfhub-styletransfer-wrapper as hub_wrapper

And call the hub evaluation function:

stylized_image = hub_wrapper.evaluate_hub('input_image.jpg', 'style_image.jpg', output_size=512, style_size=256)

This will "re-draw" the input image specified by "input_image.jpg" in a style similar to that found in the image specified by "style_image.jpg".

Note that while different style sizes can be used, the TensorFlow Hub v2 model was trained on 256x256 images, so increasing the style_size parameter any higher than 256 is not recommended.

You can also have the evaluation function plot the inputs and outputs:

stylized_image = hub_wrapper.evaluate_hub('input_image.jpg', 'style_image.jpg', output_size=512, style_size=256, plot_onoff=True)

You can then view the stylized image separately with:

hub_wrapper.show_images(stylized_image)

More examples

'Example Output' 'Example Output'

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

tfhub-styletransfer-wrapper-1.0.4.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

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