Comments (16)
import tensorflow as tf
in_path = "../output/mobilefacenet/frozen_graphs/MobileFaceNet.pb"
out_path = "../output/mobilefacenet/tflite/MobileFaceNet.tflite"
input_tensor_name = ["input"]
input_tensor_shape = {"input": [2, 112, 112, 3]}
classes_tensor_name = ["embeddings"]
converter = tf.lite.TFLiteConverter.from_frozen_graph(in_path, input_tensor_name,
classes_tensor_name, input_shapes=input_tensor_shape)
tflite_model = converter.convert()
with open(out_path, "wb") as f:
f.write(tflite_model)
from android-mobilefacenet-mtcnn-faceantispoofing.
我用你的代码依然不行,和版本有关系吗。我是1.15现在
2020-04-26 14:16:25.685949: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before general graph transformations: 1484 operators, 2717 arrays (0 quantized)
2020-04-26 14:16:25.696619: 他报这个错
F .\tensorflow/lite/toco/toco_tooling.h:38] Check failed: s.ok() Found BatchNormalization as non-selected output from Switch, but only Merge supported. Control flow ops like Switch and Merge are not generally supported. We are working on fixing this, please see the Github issue at tensorflow/tensorflow#28485.
Fatal Python error: Aborted`
from android-mobilefacenet-mtcnn-faceantispoofing.
from android-mobilefacenet-mtcnn-faceantispoofing.
哦,我不是用他原来那个pb转的,用他的ckpt重新固化一个pb,再转。
from android-mobilefacenet-mtcnn-faceantispoofing.
import os
import tensorflow as tf
from nets.MobileFaceNet import inference
training_checkpoint = "../output/mobilefacenet/MobileFaceNet_TF.ckpt"
OUTPUT_DIR = '../output/mobilefacenet/frozen_graphs'
def freeze_graph_def(sess, output_node_names):
# Replace all the variables in the graph with constants of the same values
output_graph_def = tf.compat.v1.graph_util.convert_variables_to_constants(
sess, sess.graph_def, output_node_names.split(","))
return output_graph_def
def save():
data_input = tf.placeholder(name='input', dtype=tf.float32, shape=[None, 112, 112, 3])
output, _ = inference(data_input, bottleneck_layer_size=192)
tf.identity(output, name='embeddings')
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
saver = tf.train.Saver()
saver.restore(sess, training_checkpoint)
# Freeze the graph def
output_graph_def = freeze_graph_def(sess, 'embeddings')
output_pnet = os.path.join(OUTPUT_DIR, 'MobileFaceNet.pb')
# Serialize and dump the output graph to the filesystem
with tf.gfile.GFile(output_pnet, 'wb') as f:
f.write(output_graph_def.SerializeToString())
if name == 'main':
save()
from android-mobilefacenet-mtcnn-faceantispoofing.
凑合看把 上面都是代码
from android-mobilefacenet-mtcnn-faceantispoofing.
凑合看把 上面都是代码
谢谢大佬,跪谢。
from android-mobilefacenet-mtcnn-faceantispoofing.
import os
import tensorflow as tf
from nets.MobileFaceNet import inferencetraining_checkpoint = "../output/mobilefacenet/MobileFaceNet_TF.ckpt"
OUTPUT_DIR = '../output/mobilefacenet/frozen_graphs'def freeze_graph_def(sess, output_node_names):
Replace all the variables in the graph with constants of the same values
output_graph_def = tf.compat.v1.graph_util.convert_variables_to_constants(
sess, sess.graph_def, output_node_names.split(","))
return output_graph_defdef save():
data_input = tf.placeholder(name='input', dtype=tf.float32, shape=[None, 112, 112, 3])output, _ = inference(data_input, bottleneck_layer_size=192) tf.identity(output, name='embeddings') init = tf.global_variables_initializer() with tf.Session() as sess: sess.run(init) saver = tf.train.Saver() saver.restore(sess, training_checkpoint) # Freeze the graph def output_graph_def = freeze_graph_def(sess, 'embeddings') output_pnet = os.path.join(OUTPUT_DIR, 'MobileFaceNet.pb') # Serialize and dump the output graph to the filesystem with tf.gfile.GFile(output_pnet, 'wb') as f: f.write(output_graph_def.SerializeToString())
if name == 'main':
save()
大哥,再问个问题,就是这一句output, _ = inference(data_input, bottleneck_layer_size=192)
为啥这里是192,我看他代码里写的都是128,所以说他默认的参数应该是128呀,但是,我用128转换他居然说要求192,这是啥原因。
from android-mobilefacenet-mtcnn-faceantispoofing.
我也不太清楚,我也是按报错提示改的。可能是他一些代码经过长时间修改之后对不上了。
from android-mobilefacenet-mtcnn-faceantispoofing.
from android-mobilefacenet-mtcnn-faceantispoofing.
你好,请问这个问题解决了吗?方便说一下解决方法嘛?多谢
from android-mobilefacenet-mtcnn-faceantispoofing.
你好,请问这个问题解决了吗?方便说一下解决方法嘛?多谢
你好,你可以看作者发的代码,可以解决,当时,我就是用他的代码,现在我代码找不到了。换了块硬盘,找起来费劲得很。你如果用他的代码无语,那就正好,如果有误,我就再找找
from android-mobilefacenet-mtcnn-faceantispoofing.
Hi, I'm encouting the same problem and cannot solve this. My approach is to change 'Switch' op -> 'If' and 'Merge' -> 'While' but didn't work. Any suggestion? Tks :D
from android-mobilefacenet-mtcnn-faceantispoofing.
from android-mobilefacenet-mtcnn-faceantispoofing.
But how can you export a tflite version from the model? :o
from android-mobilefacenet-mtcnn-faceantispoofing.
import tensorflow as tf
in_path = "../output/mobilefacenet/frozen_graphs/MobileFaceNet.pb" out_path = "../output/mobilefacenet/tflite/MobileFaceNet.tflite"
input_tensor_name = ["input"] input_tensor_shape = {"input": [2, 112, 112, 3]} classes_tensor_name = ["embeddings"]
converter = tf.lite.TFLiteConverter.from_frozen_graph(in_path, input_tensor_name, classes_tensor_name, input_shapes=input_tensor_shape) tflite_model = converter.convert()
with open(out_path, "wb") as f: f.write(tflite_model)
您好,为什么您这里的batchsize 设置成 2呢,不应该是1吗?
from android-mobilefacenet-mtcnn-faceantispoofing.
Related Issues (20)
- what this mean?
- why use margin when mtcnn ?
- 活体检测准确率问题 HOT 3
- Could you possibly also share how to convert the Face Anti-spoofing model to tensorflowlite? HOT 2
- more robust version HOT 1
- Pretrain for FaceAntiSpoofing
- Training the faceantispoofing model HOT 1
- 请问如何读取相册中的图片作为输入呢?
- 计算embeddings的相似度,为什么不直接用L2距离或者cosine距离,而是? HOT 2
- 你好,请问一下这里面的MTCNN和MobileFaceNet是在哪个数据集上训练的呢? HOT 1
- 我要给作者一个大大的赞 HOT 2
- 请教一下如何训练自己的FaceAntiSpoofing.tflite
- used frozen graphs HOT 6
- FaceAntiSpoofing training
- Pretrain model and testing
- Get frame live feed from camera.
- MTCNN Return Eyes points even eyes not visible in Image
- 在Android 12 时常会闪退
- Any plan to rebuilt the deep learning model ? for bette use GPU delegate
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-mobilefacenet-mtcnn-faceantispoofing.