infer_neural_style_transfer

infer_neural_style_transfer

About

1.1.3
Custom license

Neural network method to paint given image in the style of the reference image.

Task: Image generation
art
painting
deep learning

Run Neural Style Transfer algorithm.

Results

🚀 Use with Ikomia API

1. Install Ikomia API

We strongly recommend using a virtual environment. If you're not sure where to start, we offer a tutorial here.

pip install ikomia

2. Create your workflow

[Change the sample image URL to fit algorithm purpose]

from ikomia.dataprocess.workflow import Workflow
from ikomia.utils.displayIO import display

# Init your workflow
wf = Workflow()

# Add algorithm
algo = wf.add_task(name="infer_neural_style_transfer", auto_connect=True)

# Run on your image
wf.run_on(url="https://cdn.pixabay.com/photo/2017/07/11/14/22/pont-du-gard-2493762_960_720.jpg")

# Display transferred style
display(algo.get_output(1))

# Display result
display(algo.get_output(0))

☀️ Use with Ikomia Studio

Ikomia Studio offers a friendly UI with the same features as the API.

  • If you haven't started using Ikomia Studio yet, download and install it from this page.

  • For additional guidance on getting started with Ikomia Studio, check out this blog post.

📝 Set algorithm parameters

  • method (str, default="instance_norm"): method used to train the model. Must be "eccv16" or "instance_norm".
  • model_name (str, default="candy"): pre-trained model name. Model names available per method:
  • eccv16
    • the_wave
    • la_muse
    • composition_vii
    • starry_night
  • instance_norm
    • candy
    • mosaic
    • the_scream
    • udnie
    • feathers
    • la_muse
  • backend (str, default="Default"): backend.
  • target (str, default="CPU"): target.

Note: parameter key and value should be in string format when added to the dictionary.

from ikomia.dataprocess.workflow import Workflow
from ikomia.utils.displayIO import display

# Init your workflow
wf = Workflow()

# Add algorithm
algo = wf.add_task(name="infer_neural_style_transfer", auto_connect=True)

algo.set_parameters({
"method": "eccv16",
"model_name": "la_muse"
})

# Run on your image
wf.run_on(url="https://cdn.pixabay.com/photo/2017/07/11/14/22/pont-du-gard-2493762_960_720.jpg")

# Display transferred style
display(algo.get_output(1))

# Display result
display(algo.get_output(0))

🔍 Explore algorithm outputs

Every algorithm produces specific outputs, yet they can be explored them the same way using the Ikomia API. For a more in-depth understanding of managing algorithm outputs, please refer to the documentation.

import ikomia
from ikomia.dataprocess.workflow import Workflow

# Init your workflow
wf = Workflow()

# Add algorithm
algo = wf.add_task(name="infer_neural_style_transfer", auto_connect=True)

# Run on your image
wf.run_on(url="example_image.png")

# Iterate over outputs
for output in algo.get_outputs()
# Print information
print(output)
# Export it to JSON
output.to_json()

Developer

  • Ikomia
    Ikomia