jcjohnson / fast-neural-style

Feedforward style transfer
4.28k stars 815 forks source link

Cannot load pre-trained model file on android and iOS #59

Open michaelhuang74 opened 7 years ago

michaelhuang74 commented 7 years ago

Hi Everyone,

I tried to implement the stylization step on android and iOS. After generating the apps on both platforms, I tried to execute the fast_neural_style.lua using the pre-trained model file that was trained on desktop computers with Ubuntu 14.04. The stylization step was on simulators on both platforms, i.e., Android simulator from Google and Xcode from Apple.

However, the pretrained model file cannot be loaded on both simulators. The following is the error message. "File.lua:168: read error: read 0 blocks instead of 1".

I have tried all possible methods I could find online, for example, using "ascii" mode for saving and loading, using exact path for the model file, providing the "b64" or "apkbinary64" for loading, but no luck so far. On both simulators, I was able to load the sample model file that comes with the torch7-android installation package. (The sample model file is trivial and has nothing to do with the fast-neural-style application.) But I could not load the model files that were generated by the training step of this application. The training step is on 64-bit desktop computer.

Is there anyone who had successfully loaded the pre-trained model files on either android or iOS and could provide some help?

Thanks and Regards, Michael

gecong commented 7 years ago

COuld you give more details about how to run lua on mobile device?

jcjohnson commented 7 years ago

I've never tried to run Lua on either Android or iOS so I'm not sure what could be wrong. Maybe try posting on a more general Torch forum such as the gitter? https://gitter.im/torch/torch7

michaelhuang74 commented 7 years ago

@gecong Basically I created apps for torch7 on Android and iOS respectively. You can follow the instructions and examples on torch7-android and torch7-iOS.

@jcjohnson Thanks. There are same issues posted on torch7-android and torch7-ios for a quite long time. I have added some comments on the related issues on those forum. Hope someone has resolved the issue and could provide some help there.

htoyryla commented 7 years ago

"On both simulators, I was able to load the sample model file with the torch7-android, but could not load the model files that were generated by the training step of this application."

So you can load one of the example models but not what you have trained yourself? Could this have something to do with the fact that the checkpoint files are not plain model files but contain other data, too?

kaca0083 commented 7 years ago

Maybe due to the 'cudnn' option? Or other backend related stuff.

michaelhuang74 commented 7 years ago

@htoyryla The sample model file comes with the torch7-android installation package. It has nothing to do with the fast-neural-style application. For any model file of the fast-neural-style, no matter it is one of the example models or my own trained one, I could not load them on android an iOS simulators. It seems to be a torch7 or lua issue.

@kaca0083 On andriod and iOS, I was planning to run the stylization step on CPU. We used the code provided by Justin as is.

ghost commented 7 years ago

Did you solve it? Can it be run on iOS ?

dovanchan commented 7 years ago

@michaelhuang74 Did you solve it?I also wanna make a App in ios,but here have some troubles. I hope you can email me :wodovan@gmail.com,We can talk about this privately

michaelhuang74 commented 7 years ago

@dovanchan Unfortunately, I didn't figure out how to load the model on iOS.