Qualeams / Android-Face-Recognition-with-Deep-Learning-Library

Face Recognition library for Android devices is an Android library (module) which includes several face recognition methods.
Apache License 2.0
371 stars 135 forks source link

How was the optimized_facenet.pb accquried from? #15

Closed jianyin2016 closed 6 years ago

jianyin2016 commented 6 years ago

I am trying to transplant the facenet model trained in GPU to android as the part of the project does,unluckily,I got stuck as the original .pb file didn't work on the android for that the tensorflow things couldn't support some ops of the serialized model,I try to solve it by using the optimized_for_inference tools embedded in tensorflow ,and the bazel can play a same role by my understanding.but I failed。。 T^T this project has the optimized_facenet.pb which is exactly what I need and it works!even the whole project doesn't work on my PC with the reason unknown. I wander How you guys optimized the pb file so that it works on android things,please share it with me ,many many thanks!

sladomic commented 6 years ago

Hi,

I had the same problem with the Op Kernels. The problem was not the optimization but the freezing of the checkpoint model.

The mobile CPU/GPU doesn't support some operations yet and therefore the model crashes. There are basically 2 ways of fixing this

I've found this pull request https://github.com/davidsandberg/facenet/pull/240/files from another user, who had the same issue and followed the 2nd option (to remove the unnecessary, but problematic Ops).

For me this worked:

  1. Use the freeze_graph_resnet script to freeze the graph/model
  2. Then use the optimization scripts to optimize the frozen model

Regards, Michael

jianyin2016 commented 6 years ago

@sladomic Hello, Michael~ your suggestion helps!

thanks for your attention and suggestion