TF model cannot be imported to Android system

When I import a TF model in Android using SameDiff.importFrozenTF, the program goes into the indefinite wait, can anyone help me to solve this problem?

@YourPeer please convert the model to flatbuffers instead. I would also suggest you use the new tensorflow import framework first. See our support for it here:

Loading flatbuffers models is a simple SameDiff.fromFlatFile(…) and shouldn’t affect your workflow too much.

Thank you for your reply! I am now switching to keras and it is working fine. But I have another problem, because the input data shape is NHWC, but the input data shape of imported Keras is NCHW, how can I solve this problem?

Replied to your other question. You could try TF again as it should be fine. We’ve more than imported a few models at this point. I’d rather see you successful and would be happy to test both with you if there really is some sort of an issue.

Another thing to point out: Ideally, you’d import and convert your model to our format before putting it into an android application. That way you can ensure that loading is both fast (because it doesn’t need to be converted) and that it works properly in case that the model needs to be changed.

Right. As mentioned above you only need to convert it once. Conversion generally should be a separate part of the workflow anyways. We advocate for that as a way of allowing flexibility when running import. When running models and converting them you should always make sure they work as expected before deployment.

Thank you very much for your guidance! My project is trying to implement transfer learning for cell phones. Actually I want to convert it to DL4J required format on server side first and then load the .zip model from android app. Secondly, after I converted the h5 model to zip, I had the problem of mismatching data channels. Because the default data format of Keras is NCHW, however DL4J requires the input to be NHWC, I would like to know how I should solve the data channel problem in this case, should I solve the input format of the input layer of the model or to permute data channel.

Thank you very much for your guidance! I will continue to try to use the Tensorflow API tomorrow and give you feedback on the issue. My project is trying to implement transfer learning for cell phones. Actually I want to convert it to DL4J required format on server side first and then load the .zip model from android app. Secondly, after I converted the h5 model to zip, I had the problem of mismatching data channels. Because the default data format of Keras is NCHW, however DL4J requires the input to be NHWC, I would like to know how I should solve the data channel problem in this case, should I solve the input format of the input layer of the model or to permute data channel.

@YourPeer if you want (and it won’t get you in trouble with some other stakeholder) feel free to post your model for me via DM and I can take a look and test for you as well.