翻篇收录说明
翻篇网页快照

What is AI image style transfer? How it works, with examples

https://telnyx.com/learn-ai/ai-image-style-transfer

最近抓取:2026-12-05 02:22:12(北京时间)

最近内容变化:2026-12-02 13:51:18(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

AI image style transfer redraws one image in the style of another. How neural style transfer works, fast and diffusion-based methods, uses, and copyright.

正文摘录

Back to GlossaryWhat is AI image style transfer? How it works, with examplesAI image style transfer redraws one image in the style of another. How neural style transfer works, fast and diffusion-based methods, uses, and copyright.Editor: Andy MunsUpdated September 2026AI image style transfer is a technique that redraws the content of one image in the visual style of another. It keeps the layout and objects of a photo and renders them with the colors, textures, and brushwork of a painting or any other reference image. The original method uses a neural network, so it is also called neural style transfer, and the same task now runs in photo apps and in diffusion-based image editors that work differently.The original method rests on a 2015 finding by Gatys and colleagues: a network trained only to recognize objects represents what an image shows and how it looks in ways that can be pulled apart. Reading the content from one image and the style from another, then searching for a picture that matches both, lets the network paint a photo of a river town as a Van Gogh.Understanding AI image style transferAI image style transfer splits an image into two things a network can measure: content, meaning which objects appear and where, and style, meaning the textures, colors, and strokes that repeat across the picture. The method needs a content image, a style source (a reference image or, for diffusion models, a text description), and a model, and it produces one output image that keeps the content and borrows the style.Style, to a recognition network, is a set of statistics rather than a subject. It records which visual patterns tend to appear together, such as short curved strokes with deep blues, and ignores where they appear. That is why a style can be lifted from a painting of a night sky and laid over a photo of a street: the model carries over how the painting looks, not what it depicts.How AI image style transfer worksAI image style transfer works in one of two families of methods, which together cover four main types. The older family measures content and style inside a trained recognition network and changes an output image until both measurements match. Neural style transfer does that by optimizing the pixels directly, and later networks learn to do it in one pass. The newer family partially noises the photo and lets a diffusion model redraw it under a style prompt.Neural style transfer (NST)Neural style transfer, the original method from Gatys, Ecker, and Bethge, uses a convolutional neural network trained for object recognition, the VGG network. Each layer of that network produces feature maps, grids of numbers that respond to edges, textures, and eventually whole object parts, which pooling layers shrink as the image moves deeper.The content of the photo is its feature maps at one deep layer, which record what is where. The style of the painting is the correlations between feature maps at several layers, which record which patterns occur together. For the paper's figures, content was matched at one layer, conv4_2, and style at five, conv1_1 through conv5_1, with equal weight on each. Using several layers lets the style carry both fine brush texture from the early layers and larger repeating shapes from the deep ones. The output image starts as noise and is repeatedly adjusted by gradient descent until its content matches the photo and its style matches the painting.What makes the method unusual is what it optimizes. Ordinary training changes a network's weights and leaves the data alone, while neural style transfer freezes the network and changes the image itself.Technical detailsThe two measurements become two losses. The content loss is the squared difference between the output's feature maps and the photo's feature maps at the chosen layer. The style loss uses a Gram matrix for each layer: every entry multiplies two feature maps together position by position and sums the result. The entry counts how strongly two patterns appear together across the whole image, regardless of position. The style loss is the squared difference between the output's Gram matrices and the painting's.The total loss function is a weighted sum of the two, and the ratio of the weights decides the balance. A heavier style weight gives a more painterly result that drifts from the photo, and a heavier content weight keeps the photo recognizable with a lighter wash of style. Because the Gram matrix discards position, the style loss can reproduce a texture anywhere in the output, which is also why it copies brush texture well and composition not at all.Optimizations and extensionsThe original method had four clear weaknesses. It copied the painting's colors along with its texture, gave no control over which region got which style, turned photos into paintings even when a photo was the goal, and flickered on video. Later work addressed each one, with its own trade-offs. Gatys and colleagues showed how to keep the photo's own colors while taking only the painting's texture, and a follow-up added control over which regions get which style and at what scale. Luan and colleagues constrained the output to stay photorealistic in a method they called deep photo style transfer, which transfers lighting and time of day between photos without turning them into paintings. Ruder and colleagues extended the method to video by penalizing changes between frames, since styling each frame alone makes the texture flicker.Fast and arbitrary style transferOptimizing the pixels takes many passes through the network for every image. Johnson and colleagues replaced that search with a feed-forward network trained once per style, using the same content and style measurements as its training loss, which they called perceptual loss. They report results similar to the optimization method at up to three orders of magnitude faster. On a GTX Titan X GPU, their network took 0.05 seconds for a 512 by 512 image, against 10.97 to 54.85 seconds for 100 to 500 iterations of optimization. That is a speedup of 205 to 1,026 times. The catch is one network per style.Dumoulin and colleagues fit 32 styles into one network by giving each style its own normalization parameters. Normalization rescales each feature map to a chosen mean and spread, and much of a style turns out to live in those two numbers per map. Huang and Belongie removed the limit on styles altogether with adaptive instance normalization (AdaIN), which shifts the content image's features to take on the mean and variance of the style image's features. An encoder-decoder network then turns the adjusted features back into an image, for any style, in one pass. On a later Pascal Titan X GPU, the authors report 15 images per second at 512 by 512 pixels, or about 0.07 seconds each, not counting the one-time encoding of the style image. The two papers used different GPUs, so their timings are not a head-to-head comparison.Diffusion-based style transferDiffusion-based style transfer uses an image generator instead of a recognition network. A diffusion model learns to turn noise into an image step by step, so it can restyle a photo by adding partial noise and denoising it toward a new look. SDEdit introduced that approach. The image-to-image mode of Stable Diffusion uses it, run in the model's compressed image space, which is the "latent" in latent diffusion. A denoising strength setting decides how much noise is added: a little keeps the photo's structure, a lot hands more of the picture to the model. The model behind it is large. Stable Diffusion pairs an 860 million parameter denoising network with a 123 million parameter text encoder, and its README calls for a GPU with at least 10 GB of memory.Two add-ons give that process control. IP-Adapter lets a reference image steer the generator the way a text prompt would, with a weight that sets how strongly it counts. At full weight the adapter carries the reference's subject as well as its look, so style-only use means turning the weight down. ControlNet holds the structure in place by conditioning the generator on an edge map, a depth map, or a pose, so the style can change while the outline stays put. A text prompt such as "in the style of a watercolor" can also carry the style, without any reference image.Types of AI image style transferThe main types of AI image style transfer are optimization-based, per-style feed-forward, arbitrary-style, and diffusion-based methods, and the choice between them comes down to speed, flexibility, and control. Optimization-based transfer needs no training beyond the pretrained recognition network and accepts any style, but it runs a fresh search for every image, which makes it a research and art tool rather than a product feature. A per-style network is the fastest option for a fixed set of looks, such as a filter menu, and costs one training run per style. An arbitrary-style method such as AdaIN suits a feature where people upload their own style images and expect a result in real time. A diffusion-based pipeline suits editing that needs control, since it accepts a reference image or a text prompt and exposes a strength setting and structure guides. It pays for that with many denoising steps per image and a much larger model.A related family, image-to-image translation, learns a mapping between two whole collections of images rather than copying one reference. Despite the similar name, it is a different thing from Stable Diffusion's image-to-image mode, which edits one photo at a time. CycleGAN, for example, learned to turn photos into paintings in the style of Monet from unpaired sets of each. It trains two networks against each other, one generating paintings and one judging whether they look real, and adds a cycle-consistency loss: a photo turned into a painting and back should return the original photo. It transfers a collection's look, not a single picture's.The styles themselves are open-ended. Any image with a consistent look can s