infer_neural_style_transfer
About
Neural network method to paint given image in the style of the reference image.
Run Neural Style Transfer algorithm.
🚀 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 Workflowfrom ikomia.utils.displayIO import display# Init your workflowwf = Workflow()# Add algorithmalgo = wf.add_task(name="infer_neural_style_transfer", auto_connect=True)# Run on your imagewf.run_on(url="https://cdn.pixabay.com/photo/2017/07/11/14/22/pont-du-gard-2493762_960_720.jpg")# Display transferred styledisplay(algo.get_output(1))# Display resultdisplay(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 Workflowfrom ikomia.utils.displayIO import display# Init your workflowwf = Workflow()# Add algorithmalgo = wf.add_task(name="infer_neural_style_transfer", auto_connect=True)algo.set_parameters({"method": "eccv16","model_name": "la_muse"})# Run on your imagewf.run_on(url="https://cdn.pixabay.com/photo/2017/07/11/14/22/pont-du-gard-2493762_960_720.jpg")# Display transferred styledisplay(algo.get_output(1))# Display resultdisplay(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 ikomiafrom ikomia.dataprocess.workflow import Workflow# Init your workflowwf = Workflow()# Add algorithmalgo = wf.add_task(name="infer_neural_style_transfer", auto_connect=True)# Run on your imagewf.run_on(url="example_image.png")# Iterate over outputsfor output in algo.get_outputs()# Print informationprint(output)# Export it to JSONoutput.to_json()
Developer
Ikomia