I’m running v12 now and ImageRestyle[] crashes for me on an image of size 1600 x 1200 pixels.

All the examples in the documentation use images around 500 x 500 or smaller. So, how can I get this to work on high resolution images?

We can't simply map it over sub-windows of the image:

p = ImagePartition[i, 100];
ImageAssemble[Map[ImageRestyle[#, s, PreserveColor -> True, 
 PerformanceGoal -> "Quality", RandomSeeding -> 1] &, p, {2}]];

enter image description here

I need to ImageRestyle images of 4 or more megapixels in size. Is there someway to get this to use a GPU?

  • $\begingroup$ If we could somehow enforce edge constraints on the sub windows the partitioning idea might work. $\endgroup$
    – M.R.
    Oct 2, 2017 at 16:22
  • $\begingroup$ In my 32G memory machine,I think it is possible.. :) $\endgroup$
    – yode
    Oct 5, 2017 at 15:22
  • $\begingroup$ I tried using Inpaint on the partition edges to smooth them. It's reasonably effective. $\endgroup$
    – b3m2a1
    Oct 23, 2017 at 4:31
  • 1
    $\begingroup$ @M.R. No way for larger images. However, I have tried to downscale the image, then restyle, and, again, to upscale it. The idea can work as the restyling seems to blur the resulting image a bit. So, upscaling should not show a clear detail reduction. Using ImageResize in downscaling as well as in upscaling, with a proper resampling, could help to minimize the effect of reducing details. $\endgroup$ Oct 24, 2017 at 8:00
  • 1
    $\begingroup$ Install the free Wolfram Engine on a big cloud instance. On AWS you can go up to 2 Tera of RAM. Check github.com/Ludwiggle/JWLS to connect to a remote kernel $\endgroup$
    – Fortsaint
    Jun 28, 2019 at 8:26

1 Answer 1


I'd like to answer this old question, because the issue seems to be resolve in later versions of Wolfram Language.

14.0.0 for Mac OS X x86 (64-bit) 

I get the following target image:

image = Import["https://wolfr.am/1iHhr31lO"]
image // ImageDimensions

enter image description here

and the following style:


enter image description here

And the following result and timing on purely standard MacBook Pro 6 CPU cores:

ImageRestyle[image, style] // AbsoluteTiming

enter image description here

These 2 options are probably best tried always together:

PerformanceGoal -> "Quality", 
TargetDevice -> "GPU"

You can also try using this neural net, especially see section "Adapt to any size":


Automatic image resizing can be avoided by replacing the net encoders. First get the net:

net = NetModel[
  "AdaIN-Style Trained on MS-COCO and Painter by Numbers Data"]

Extract the original mean channel values:

meanRGB = NetExtract[net, "Content"][["MeanImage"]]

{0.48502, 0.457957, 0.407604}

Create the new net encoders with the desired dimensions:


Attach the new net encoders:

resizedNet = 
 NetReplacePart[net, {"Content" -> netEncC, "Style" -> netEncS, 
   "Output" -> NetDecoder["Image"]}]

Restyle an image using the new resized network:


enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.