-
Notifications
You must be signed in to change notification settings - Fork 55
Output Stylized Image looks different on torch and coreml #6
Comments
my first thoughts that it's related to this part of the code
|
@engahmed1190 I can try to investigate and debug this problem if you could attach your torch7 model. |
here is the torch model |
@engahmed1190 I tried to run the model which you provided with latest torch7 installation (without CUDA on macOS) using this command: th fast_neural_style.lua -model home.jpeg_700.t7 -input_image test.jpg -output_image test_result.jpg So it looks like your output from CoreML. May be something inconsistent with torch7 installation or with fast-neural-style repo revision that you use. |
i have tried the same model but different result |
can you suggest a solution for this case @opedge |
I've noticed that all new instance norm models don't work when converted to coreml. Also, all historical models in fast-neural-style don't work in torch. Have yet to figure out the connection. |
I found an older machine with an older torch setup (~ 6 months) and the server images for old models generate fine. I then stepped through the updates that I had applied to the newer machine. luarocks install torch The server started screwing up image generation for old models after applying the "luarocks install nn" step. This makes sense I believe because the pytorch convert step always screws up on new models and I suspect it has something to do with the use of "from torch.nn import InstanceNorm3d". |
Ive also been having issues with instance normalization models that i have trained in torch and converted to coreml. Even training with the exact same parameters as the johnson pretrained models it causes issues. Im trying now with batch normalization. |
Yeah, batch works but lower quality and/or bigger model. |
For appropriate conversion may be you need to implement InstanceNorm layer by yourself like I did in sample converter but using another algorithms than InstanceNorm3d layer from pytorch. |
If your still interested about instance normalization i ended up using this pytorch https://github.com/abhiskk/fast-neural-style implementation, and its instance normalization works straight off the bat. I adjusted the current torch2coreml implementation and adjusted it to convert the pretrained models present in the link above, directly from pytorch instead of legacy torch. This is their instance normalization code.
|
@AndreJFBico sounds great! May you'd like to make a PR for your pytorch models support and instance_norm layer? |
@AndreJFBico can you please provide the modified torch2coreml code for direct conversion from PyTorch pre-trained model to CoreML? |
I have used same image on both models , Torch model present a good output while the Coreml model changes the main picture color .
i used this image for testing

the output from torch model is

Coreml model provides this

the model trained options
The text was updated successfully, but these errors were encountered: