610265158 / face_landmark

A simple method for face alignment based on wingloss and mutitask learning :)
Apache License 2.0
251 stars 80 forks source link

some error occurred when i convert the model to MNN model~ #4

Closed MirrorYuChen closed 4 years ago

MirrorYuChen commented 4 years ago

the details of error informations is below:

{19-10-02 11:56}mirror:~/MNN/tools/converter/build@master✗✗✗✗✗✗ mirror% ./MNN Convert -f TF --modelFile keypoints.pb --MNNModel xxx.mnn --bizCode biz MNNConverter Version: 0.0.0.1 - MNN @ 2018

Start to Convert Other Model Format To MNN Model... terminate called after throwing an instance of 'Error' what(): [11:57:21] /home/mirror/MNN/tools/converter/source/tensorflow/TmpG raph.cpp:316: Check failed: inputNode->opType == "Const" ==> FusedBatchNorm|SpaceToBatchND Lack Const Tensor[1] 10624 abort (core dumped) ./MNNConvert -f TF --modelFile keypoints.pb --MNNModel xxx.mnn --bizCode biz

I found there is an similar issues in MNN project: https://github.com/alibaba/MNN/issues/358

如果使用了bn,生成pb时将bn层training参数设为False; 如果使用了dilation conv,需要固定输入图像大小,然后重新生成pb。

I wanna to kown how to set these layers, can you give me some advice ?

610265158 commented 4 years ago

the details of error informations is below:

{19-10-02 11:56}mirror:~/MNN/tools/converter/build@master✗✗✗✗✗✗ mirror% ./MNN Convert -f TF --modelFile keypoints.pb --MNNModel xxx.mnn --bizCode biz MNNConverter Version: 0.0.0.1 - MNN @ 2018

Start to Convert Other Model Format To MNN Model... terminate called after throwing an instance of 'Error' what(): [11:57:21] /home/mirror/MNN/tools/converter/source/tensorflow/TmpG raph.cpp:316: Check failed: inputNode->opType == "Const" ==> FusedBatchNorm|SpaceToBatchND Lack Const Tensor[1] 10624 abort (core dumped) ./MNNConvert -f TF --modelFile keypoints.pb --MNNModel xxx.mnn --bizCode biz

I found there is an similar issues in MNN project: alibaba/MNN#358

如果使用了bn,生成pb时将bn层training参数设为False; 如果使用了dilation conv,需要固定输入图像大小,然后重新生成pb。

I wanna to kown how to set these layers, can you give me some advice ?

You should rebuild the graph with bn training flag as False. rebuild the graph with the bn layer as False, load the trained params, and save it.

MirrorYuChen commented 4 years ago

You mean set flag: use_batch_norm to false?

610265158 commented 4 years ago

You mean set flag: use_batch_norm to false?

In tensorflow, a placeholder was used to control the bn layer, so when inference a bool value should be fed.

e.g. is_training=training in below codes net, end_points=shufflenet_v2(images,is_training=training,depth_multiplier='1.0')

The converter of some inference framworks, including tflite, the flag shoule be set as a constant other than a placeholder.

MirrorYuChen commented 4 years ago

Thank you very much, I will have a try~