ProGamerGov / neural-style-pt

PyTorch implementation of neural style transfer algorithm
MIT License
834 stars 178 forks source link

Procedure for converting caffe models to .pth #8

Closed ajhool closed 5 years ago

ajhool commented 5 years ago

I assume that the vgg16 and vgg19 models in the download scripts are the same models as the initial lua implementation, except that they were converted them to pytorch. Do you recall how you did that?

I ask partly because I'm interested in doing the same, but also because I'm curious whether the mean values of used in the preprocess and deprocess Normalization steps correspond to the correct models -- I'm seeing artifacts that I hadn't seen in the lua implementation and am trying to track it down.

(Nice work, btw!)

ProGamerGov commented 5 years ago

Yes, they are the same model. They were converted originally to PyTorch's .pth format by Justin Johnson here: https://github.com/jcjohnson/pytorch-vgg

ajhool commented 5 years ago

Sorry, I hadn't initially noticed the s3 path

ProGamerGov commented 5 years ago

I have a Wiki link here too, with a link to a variation of pytorch-vgg that uses neural-style-pt's model definitions instead of using Torchvision's definitions: https://github.com/ProGamerGov/neural-style-pt/wiki/Converting-Caffemodels-To-PyTorch. If Torchvision changed it's definitions, then my variation should still work.

ProGamerGov commented 4 years ago

I built a script to change a model's weight bias names to values that compatible with neural-style-pt: https://gist.github.com/ProGamerGov/1bc833a8ae91f81e7e40037d052f8193

If you convert a model and want to easily fix the names, or come across a pytorch model with caffe preprocessing, then you can use the script to make it usable in neural-style-pt.