Jump to content
How to Install Plugins ×

Style Transfer Effect


Pat L

Recommended Posts

Style Transfer Effect

 

Example.png

 

Download the Installer from Github (warning - 53 MB download 😟)

 

Requirements:

  • Paint.NET v4.2.* (tested with 4.2.8)
  • Windows 7 or later, 64 bit version (sorry about that😟)
  • a lot of RAM (should work fine with 8 GB, but 16 GB or more are recommended, especially for bigger images)
  • a fast CPU (no GPU hardware acceleration at this point) - it can take a long time to render the effect

 

Supported UI languages:

  • English (including British English to put the "U" back in colour☺️)
  • German
  • French
  • Portuguese
  • Spanish
  • Russian

 

Let me know, if you can help me with adding languages or improve the existing localisation.

 

You can find the effect under "Effects->Artistic->Style Transfer".

 

But what does it do?

 

This effect can be used to transfer the style of one image to another.

The effect uses neural networks trained on a bunch of images to achieve this.

You can either select a style from list of presets (including a fancy before-and-after-slider for viewing an example):

plugin_preset_example.png

 

The "Stylize Amount"-slider lets you adjust the ratio between the selected style and the content image style.

Note that this is not a simple alpha-blend, though.
Even selecting zero ("0") will change the content image significantly, as the model tries to apply the style extracted

from the content to the content itself. This process isn't perfect by any means, so keep that in mind.
 

"Style Extraction" and "Style Transfer" models can be selected as well.

The "High Quality" setting uses a larger model for extracting and transferring styles.

The "Fast"-option selects a smaller, "distilled" version of the higher quality one that requires less memory and less CPU power.

The results will be very different between the models and depending on the selected style and amount,you might even prefer one over the other.
 

 

Or you can create your own style by using an image of your choice:

plugin_custom_style.png

 

Clicking the "Select Style Image"-button or clicking the style image preview directly, will open a file dialog for image selection.

The "Style Image Size"-slider determines the relative scaling factor of the style image that is used before the style is analysed.

Think of it as how much of the style image the model is allowed to "see" before the style is extracted.
The coloured bar below the slider indicates a size range that will probably yield the best-looking results, with the green arrow pointing at the recommended value.
You can select values outside this range (though RAM and minimum size restrictions still apply), but the results may not be as good.

The plugin will display a warning, if you choose a combination of a big style image and large style size:
plugin_custom_style_warning.png

 

This happens, because the processing requires a large amount of RAM and once you use more RAM than is physically installed in your computer,

your system will crawl to a halt, become unresponsive, and eventually even crash Paint.NET.
The plugin will not use your settings, if they would result in too much RAM being used to protect the system from running out of memory.

 

I hope you find this effect useful and have as much fun playing around with it as I had creating it ☺️!

 

PS: the source code is available on Github - if you can, please use Github to report any issues, bugs, and feature requests.

Edited by Pat L
added another example image
  • Like 5
  • Upvote 1
Link to comment
Share on other sites

Hello & welcome Pat.

 

Wow. That's quite an introduction B) I'm  impressed. The list of presets is fabulous. I'm off to play with this new toy. Thank you!

Link to comment
Share on other sites

2 hours ago, homebrew said:

fine results,  but takes too much time to be applied, between 1 and 2 mn (24Go RAM), without real time preview.  don't know if  i'm mistaken.

Yeah, quite time consuming - even if you cancel. Seems to go thru all the segments even though you click cancel.

 

but, but, THANK YOU!

Link to comment
Share on other sites

37 minutes ago, Panchdara said:

Yeah, quite time consuming - even if you cancel. Seems to go thru all the segments even though you click cancel.

 

but, but, THANK YOU!

 

Yes, unfortunately proper support for "Cancel" is currently on the todo-list. Well that and support for GPU-accelerated processing.

I am currently looking at a few options on how to achieve this, so stay tuned for updates👍

Link to comment
Share on other sites

Wow! Really impressed with this @Pat L.

 

Got a lot of things racing in my head now.  Thanks for this!  :star: :)

 

styletransfer_orig.pngstyletransfer.png  

Magical!

 

Edited by lynxster4
  • Like 2
Link to comment
Share on other sites

Can anyone elaborate on the installation?  I installed NSIS, the Installer.nsi file didn't compile, so I compiled the zip and that worked (I think) but it just gave me a very similar looking folder and another Installer.nsi file that didn't compile

Link to comment
Share on other sites

Oh wow I got a different github link and came here just because there wasn't a forum where I got it.  Been trying to build the project in visual studio for hours.  You're a life saver

Link to comment
Share on other sites

The information at the github link seems to be for ByteHeads. I am pleased that an installer was provided.
( Even providing the .dll would have been just as good for me.)

Edited by HyReZ


 

Link to comment
Share on other sites

  • 1 year later...

The installer is saying I don't have it installed and then just closes, could it be because I purchased it through the microsoft store? Could I just directly download the dll and other necessary files somehow?

Link to comment
Share on other sites

57 minutes ago, SabreS said:

could it be because I purchased it through the microsoft store?

 

Yes, the folders are in different place from the Classic.

 

Please read 1/2 way down this thread on how and where to put the Effects folder:

 

Install Plugins (getpaint.net)

30b8T8B.gif

How I made Jennifer & Halle in Paint.net

My Gallery | My Deviant Art

"Rescuing one animal may not change the world, but for that animal their world is changed forever!" anon.

 
Link to comment
Share on other sites

4 hours ago, SabreS said:

Could I just directly download the dll and other necessary files somehow?

7-Zip is the only archiver that could open the file StyleTransferEffect-Installer.exe. Right click on StyleTransferEffect-Installer.exe and select Extract.

 

In the StyleTransferEffect-Installer folder that the archiver created, select the files shown in the image below (including the folder with your native language file).

 

files.png.d16f1eb0110d26e75b966ef62244640a.png

Move these files to your folder Documents\paint.net App Files\Effects.

 

But... After applying this effect, you will get the following error message:

Spoiler

File: D:\Пользователи\Документы\paint.net App Files\Effects\StyleTransferEffect.dll
      Effect Name: PaintDotNet.Effects.ML.StyleTransfer.Plugin.StyleTransferEffect
      Full error message: PaintDotNet.WorkerThreadException: Worker thread threw an exception ---> System.MethodAccessException: Attempt by method 'PaintDotNet.Effects.ML.StyleTransfer.Plugin.StyleTransferEffect.OnRender(System.Drawing.Rectangle[], Int32, Int32)' to access method 'PaintDotNet.RenderArgs.get_ISurface()' failed.
   at PaintDotNet.Effects.ML.StyleTransfer.Plugin.StyleTransferEffect.OnRender(Rectangle[] renderRects, Int32 startIndex, Int32 length)
   at PaintDotNet.Effects.ML.StyleTransfer.Plugin.StyleTransferEffect.OnSetRenderInfo(StyleTransferEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
   at PaintDotNet.Effects.Effect`1.OnSetRenderInfo(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs) in D:\src\pdn\src\Effects\Effect`1.cs:line 71
   at PaintDotNet.Effects.BackgroundEffectRenderer.ThreadFunction() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 268
   --- End of inner exception stack trace ---
   at PaintDotNet.Effects.BackgroundEffectRenderer.DrainExceptions() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 447
   at PaintDotNet.Menus.EffectMenuBase.DoEffect(Effect effect, EffectConfigToken token, Result`1 lazySelectionScans, Result`1 lazyRegionToRenderScans, Result`1 lazyClipMaskRenderer, Surface originalSurface, Exception& exception) in D:\src\pdn\src\PaintDotNet\Menus\EffectMenuBase.cs:line 0

 

Unfortunately, @Pat L last visited the forum on January 17, 2020. However, he was on github three weeks ago. You can tell him there about the detected failure and maybe he will fix the problem.

Link to comment
Share on other sites

I have been trying to report this crash for weeks. The thread was not allowing me to save my replies. I believe the latest update to Paint.Net is somehow causing the crashes.

  • Upvote 1

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

11 hours ago, AndrewDavid said:

I believe the latest update to Paint.Net is somehow causing the crashes.

 

I think the MS updates are causing havoc.  I too have been experiencing many strange happenings of late.  Also, does @Red ochre

 

30b8T8B.gif

How I made Jennifer & Halle in Paint.net

My Gallery | My Deviant Art

"Rescuing one animal may not change the world, but for that animal their world is changed forever!" anon.

 
Link to comment
Share on other sites

I did get 4 updates to Win 10 last night, but the error is still occurring. Now that I can post, I've included my crash log.

Spoiler

File: C:\Program Files\paint.net\Effects\StyleTransferEffect.dll
      Effect Name: PaintDotNet.Effects.ML.StyleTransfer.Plugin.StyleTransferEffect
      Full error message: PaintDotNet.WorkerThreadException: Worker thread threw an exception ---> System.MethodAccessException: Attempt by method 'PaintDotNet.Effects.ML.StyleTransfer.Plugin.StyleTransferEffect.OnRender(System.Drawing.Rectangle[], Int32, Int32)' to access method 'PaintDotNet.RenderArgs.get_ISurface()' failed.
   at PaintDotNet.Effects.ML.StyleTransfer.Plugin.StyleTransferEffect.OnRender(Rectangle[] renderRects, Int32 startIndex, Int32 length)
   at PaintDotNet.Effects.ML.StyleTransfer.Plugin.StyleTransferEffect.OnSetRenderInfo(StyleTransferEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
   at PaintDotNet.Effects.Effect`1.OnSetRenderInfo(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs) in D:\src\pdn\src\Effects\Effect`1.cs:line 71
   at PaintDotNet.Effects.BackgroundEffectRenderer.ThreadFunction() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 268
   --- End of inner exception stack trace ---
   at PaintDotNet.Effects.BackgroundEffectRenderer.DrainExceptions() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 447
   at PaintDotNet.Menus.EffectMenuBase.DoEffect(Effect effect, EffectConfigToken token, Result`1 lazySelectionScans, Result`1 lazyRegionToRenderScans, Result`1 lazyClipMaskRenderer, Surface originalSurface, Exception& exception) in D:\src\pdn\src\PaintDotNet\Menus\EffectMenuBase.cs:line 0


 


 

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

13 hours ago, AndrewDavid said:

I believe the latest update to Paint.Net is somehow causing the crashes.

 

It looks like @toe_head2001 submitted a patch on GitHub, so the author should hopefully make an update available soon.

  • Upvote 1

PdnSig.png

Plugin Pack | PSFilterPdn | Content Aware Fill | G'MICPaint Shop Pro Filetype | RAW Filetype | WebP Filetype

The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait

 

Link to comment
Share on other sites

  • 1 year later...

hi there i donwload the plugin it just says errors what do i do. tried my best but seem to not work. oh yeah heres the error it gives me 

File: S:\paint.net\Effects\StyleTransferEffect.dll
      Effect Name: PaintDotNet.Effects.ML.StyleTransfer.Plugin.StyleTransferEffect
      Full error message: PaintDotNet.WorkerThreadException: Worker thread threw an exception
 ---> Microsoft.ML.OnnxRuntime.OnnxRuntimeException: [ErrorCode:Fail] D:\Repos\onnxruntime\onnxruntime\core\session\inference_session.cc:262 onnxruntime::InferenceSession::InferenceSession result was false. Could not parse model successfully while constructing the inference session

   at Microsoft.ML.OnnxRuntime.NativeApiStatus.VerifySuccess(IntPtr nativeStatus)
   at Microsoft.ML.OnnxRuntime.InferenceSession.Init(Byte[] modelData, SessionOptions options)
   at PaintDotNet.Effects.ML.StyleTransfer.EffectModel.Reset(Byte[] modelData)
   at PaintDotNet.Effects.ML.StyleTransfer.Plugin.StyleTransferEffect.OnSetRenderInfo(StyleTransferEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
   at PaintDotNet.Effects.Effect`1.OnSetRenderInfo(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs) in D:\src\pdn\src_4_3_x\Effects\Effect`1.cs:line 68
   at PaintDotNet.Effects.BackgroundEffectRenderer.ThreadFunction() in D:\src\pdn\src_4_3_x\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 266
   --- End of inner exception stack trace ---

 

Edited by bruh_where_cheese
Link to comment
Share on other sites

13 hours ago, bruh_where_cheese said:

ried my best but seem to not work.

 

Yes, this Plugin is not working.  I will post the Error message on the developer's Git Hub page, as requested.  Hopefully this can be fixed.

EDIT:  The developer has responded and is working on it :) 

  • Upvote 1
  • Hooray 1

30b8T8B.gif

How I made Jennifer & Halle in Paint.net

My Gallery | My Deviant Art

"Rescuing one animal may not change the world, but for that animal their world is changed forever!" anon.

 
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...