crowsonkb / style-transfer-pytorch

Neural style transfer in PyTorch.
MIT License
475 stars 113 forks source link

Use several style images #14

Open Daniel63656 opened 2 years ago

Daniel63656 commented 2 years ago

Hello can someone tell me the syntax if i want to hand over a list of style images?

terekita commented 2 years ago

I don't know enough about python to fully explain this, but after finding myself unable to the use the 'content' and 'styles' arguments the way I expected, I edited lines 155 and 156 in cli.py to be the following: p.add_argument('-content', type=str, help='the content image') p.add_argument('-styles', type=str, nargs='+', metavar='style', help='the style images') (added the dash in front of both content and style).

After that, you can do command like: cw = 0.015 * 1 #this is the content weight—make it a larger number to emphasize the content !style_transfer -content 'file1.jpg' -styles 'style1.jpg' -cw $cw -s 512

Then, if you want multiple style images, you can do

!style_transfer -content afile1.jpg -styles style1.jpg style2.jpg -sw 0.5 3.75 -cw $cw -s 512

The two numbers after -sw are the weights for the two files that you specify after -styles. If you want more than two, then simply list more than 2 files after -styles, and supply the corresponding number of weights after -sw.

Apologies for any jankiness, but I hope that at least helps you get closer to what you are looking for..

meefs commented 2 years ago

@Daniel63656 ,

The program uses the first file supplied as content and the rest as styles. Using the example below I have been able to run multiple styles:

./style_transfer /path/to/content.jpg /path/to/style1.jpg /path/to/style2.jpg /path/to/style3.jpg ...

Hope this helps.