Programmable Media

Neural Artwork Style Transfer

Last updated: Apr-08-2024

The Neural Artwork Style Transfer add-on has been deprecated.

Cloudinary is a cloud-based service that provides solutions for image and video management, including server or client-side upload, on-the-fly image and video transformations, quick CDN delivery, and a variety of asset management options.

The Neural Artwork Style Transfer add-on takes Cloudinary image transformations to a new level with the style_transfer effect. This effect applies a complex deep learning neural network algorithm that extracts artistic styles from a source image and applies them to the content of a target photograph.

Getting started

Before you can use the Neural Art Style Transfer add-on:

  • You must have a Cloudinary account. If you don't already have one, you can sign up for a free account.

  • Register for the add-on: make sure you're logged in to your account and then go to the Add-ons page. For more information about add-on registrations, see Registering for add-ons.

  • Keep in mind that many of the examples on this page use our SDKs. For SDK installation and configuration details, see the relevant SDK guide.

  • If you are new to Cloudinary, you may want to take a look at How to integrate Cloudinary in your app for a walk through on the basics of creating and setting up your account, working with SDKs, and then uploading, transforming and delivering assets.

By default, delivery URLs that use this add-on either need to be signed or eagerly generated. You can optionally remove this requirement by selecting this add-on in the Allow unsigned add-on transformations section of the Security page in the Console Settings. (Cloudinary's demo product environment has this setting applied to make the examples on this page easier to read and try out.)


Gatys et al is credited with using the VGG neural network to demonstrate how different abstractions of the source and target images can be filtered at different layers, so that the essential elements of the input image can be applied without losing the essence of the target content. Cloudinary's algorithm takes advantage of Xun Huange and Serge Belongie's enhancement on the Gatys algorithm, which make it possible to use any image for both source and target, and still deliver a good quality style transfer in real time, using a single feed-forward neural network.

To apply this style transfer effect on any photograph, specify the public ID of the source artwork as an image overlay (l_ in URLs) and style_transfer as the overlay effect (e_style_transfer in URLs) to apply (include this effect in the layer_apply component of your URL). The target photograph is the public ID of the image to deliver.

The same layer transformation syntax rules apply, including for authenticated or private assets.

In the example below, the styles of the Sailing Angel artwork are transferred to the Golden Gate Bridge photo:

Sailing angel - source artwork Source artwork Golden gate bridge - target photo Target photo Style transfer result Style transfer result

To apply this transformation using the Transformation Editor, first select to Add overlay & watermark and specify the source artwork's Image ID. Then select Style transfer as the effect of the overlay image.

Adjusting style transformation preferences

The algorithm is able to recognize styles in the source painting, such as brush stroke style, textures, and dominant colors. It can then apply those styles to the content elements of the target photograph. In the resulting image, there is some content loss, and some style loss, but the neural network algorithm optimizes these losses so that the main elements of the artwork's style come through while ensuring that the content of the target photo is clearly recognizable.

  • If you want to retain the target photograph's colors, you can include the preserve_color option.
  • If you want to control how much of the style from the source painting is transferred, you can adjust the style_strength (1-100, default: 100).

For example, if you transfer the styles of the lighthouse source artwork to the beach_2_kids target photo, you clearly get a result that is heavily influenced by the lighthouse image's colors and brushstroke styles:

Lighthouse - source artwork Source artwork Beach - target photo Target photo Style transfer result Default style transfer

Now take a look at the next three images to see how the result changes with the use of the adjustment settings:

Style transfer with colors preserved Preserve original colors Style transfer with strength 60 Adjust style strength
to 60
Style transfer with adjusted strength and colors preserved Adjust strength and
preserve colors

Here's the transformation code for that last image, using both the preserve_color and style_strength options:

Setting the image size

The Neural Artwork add-on supports generating images with the style_transfer effect for any resolution up to 3000x3000, and it's capable of rendering the new image very quickly even at large sizes. However, because of the way the algorithm analyzes the content of the target photo, you will get different results for different sizes of the target photo. Also, keep in mind that the neural network algorithm behind our Neural Artwork add-on was initially designed for optimum output of images at resolutions in the range of 600x600 - 800x800.

Therefore, when this optimum resolution range is appropriate for your intended usage, use resize or cropping transformations to bring the target photo into this range in one transformation component, and then apply the style_transfer effect in a later transformation component.

For example: ....c_scale,w_700/l_your_artwork/e_style_transfer,fl_layer_apply/your_target_photo.jpg

Likewise, if you want to output images that are significantly smaller than the above recommended resolution range, you may want to apply the style_transfer effect in an earlier transformation component, and then apply the resizing to the small size in a later transformation component.

For example: ....c_scale,w_700/l_your_artwork/e_style_transfer,fl_layer_apply/c_scale,w_200/your_target_photo.jpg

Signed URLs

Cloudinary's dynamic image transformation URLs are powerful tools for agile web and mobile development. However, due to the potential costs of your customers accessing unplanned dynamic URLs that apply the neural art algorithm, image transformation add-on URLs are required (by default) to be signed using Cloudinary's authenticated API or, alternatively, you can eagerly generate the requested derived images using Cloudinary's authenticated API.

To create a signed Cloudinary URL, set the sign_url parameter to true when building a URL or creating an image tag.

The following code example generates a neural artwork by overlaying the davinci_mona_lisa artwork with the coffee_cup_st photo, including a signed Cloudinary URL:

Code for generating neural artwork with signed URL

The generated Cloudinary URL shown below includes a signature component (/s--D2UmnV-Z--/). Only URLs with a valid signature that matches the requested image transformation will be approved for on-the-fly image transformation and delivery.

For more details on signed URLs, see Signed delivery URLs.

You can optionally remove the signed URL default requirement for a particular add-on by selecting it in the Allow unsigned add-on transformations section of the Security Settings in the Cloudinary Console.

Neural artwork add-on demo

1   Pick an artwork:

2   Pick a target photo below OR    Upload your own
golf course target photo coffee target photo old man target photo If you upload a picture, it will appear here

3   Press the magic button:

More on Cloudinary transformations

You can create even more unique results by combining the Neural Artwork style_transfer effect with other transformations. For details, see Image transformations and the Transformation URL API Reference.

✔️ Feedback sent!

Rate this page: