Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

Can't convert model.t7 to mlmodel #18

Open
markzhong88 opened this issue Nov 15, 2017 · 2 comments
Open

Can't convert model.t7 to mlmodel #18

markzhong88 opened this issue Nov 15, 2017 · 2 comments

Comments

@markzhong88
Copy link

markzhong88 commented Nov 15, 2017

Great open source project.

I trained some .t7 model form the DmitryUlyanov texture nets, it's same method with Justin Johnson's fast feed forward.
https://github.com/DmitryUlyanov/texture_nets#credits

Here is a sample model download link:
https://yadi.sk/d/GwL9jNJovBwQg

When I tried to convert it to mlmodel using convert-fast-neural-style.py, it shows me NotType Error, or unknown Torch class <nn.TVLoss>...

@opedge
Copy link
Member

opedge commented Nov 17, 2017

You need to prepare your model for inference. Loss layer is not needed for inference, you can safely remove it from the model. I made a script for fast-neural-style which modifies models: https://github.com/prisma-ai/torch2coreml/blob/master/example/fast-neural-style/prepare_model.lua You can implement something similar for your model. Please note, that currently not all torch7 layers are supported and you cannot convert model with custom Lua layers inside. Please refer to example with custom layer implementation https://github.com/prisma-ai/torch2coreml/blob/master/example/fast-neural-style/convert-fast-neural-style.py#L12 if you need some unknown layers to be converted.

@theheena
Copy link

theheena commented Nov 28, 2017

Hi @opedge ,
I have a model from Justin Johnson and want to convert it to coreml model. So I first tried to prepare the model using prepare_model.lua but it gave following error. Please let me know how can I solve this problem,
no file './fast-neural-style/fast_neural_style/ShaveImage.lua'
no file '/home/torch/install/share/luajit-2.1.0-beta1/fast-neural-style/fast_neural_style/ShaveIma
ge.lua'
no file '/usr/local/share/lua/5.1/fast-neural-style/fast_neural_style/ShaveImage.lua'
no file '/usr/local/share/lua/5.1/fast-neural-style/fast_neural_style/ShaveImage/init.lua'
no file '/home/.luarocks/lib/lua/5.1/fast-neural-style/fast_neural_style/ShaveImage.so'
no file '/home/torch/install/lib/lua/5.1/fast-neural-style/fast_neural_style/ShaveImage.so'
no file '/home/torch/install/lib/fast-neural-style/fast_neural_style/ShaveImage.so'
no file './fast-neural-style/fast_neural_style/ShaveImage.so'
no file '/usr/local/lib/lua/5.1/fast-neural-style/fast_neural_style/ShaveImage.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file '/home/.luarocks/lib/lua/5.1/fast-neural-style.so'
no file '/home/torch/install/lib/lua/5.1/fast-neural-style.so'
no file '/home/torch/install/lib/fast-neural-style.so'
no file './fast-neural-style.so'
no file '/usr/local/lib/lua/5.1/fast-neural-style.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'error'
/home/torch/install/share/lua/5.1/trepl/init.lua:389: in function 'require'
example/fast-neural-style/prepare_model.lua:4: in main chunk
[C]: in function 'dofile'
...eena/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
[C]: at 0x55917c228470

The command which I used to run the code for preparing model is:
th example/f ast-neural-style/prepare_model.lua -input example/fast-neural-style/candy.t7 -output example/fast-neural-style/p ytorch_models/candy1.t7

Please guide me in this.
Thank you

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants