Open3
WHENetのエクスポート
docker run --rm -it --gpus all \
-v `pwd`:/home/user/workdir \
-v /tmp/.X11-unix/:/tmp/.X11-unix:rw \
--device /dev/video0:/dev/video0:mwr \
--net=host \
-e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
-e DISPLAY=$DISPLAY \
--privileged \
pinto0309/whenet:latest /bin/bash
git clone https://github.com/Ascend-Research/HeadPoseEstimation-WHENet.git
cd HeadPoseEstimation-WHENet
pip3 install gdown
gdown --id 1wGrwu_5etcpuu_sLIXl9Nu0dwNc8YXIH -O yolo_v3/data/head_detect.h5
python3 demo_video.py \
--video 0 \
--display simple \
--output output.mp4
whenet.py
if snapshot!=None:
self.model.load_weights(snapshot)
for l in self.model.layers[1:]:
l.trainable = False
self.model.summary()
self.model.save('model.h5')
import tensorflow as tf
from keras.models import load_model
from keras import backend as K
from tensorflow.python.framework import graph_io
from tensorflow.python.framework import graph_util
def freeze_graph(session, output, save_pb_dir='.', save_pb_name='frozen_model.pb', save_pb_as_text=False):
graph = session.graph
with graph.as_default():
graphdef_inf = tf.graph_util.remove_training_nodes(graph.as_graph_def())
graphdef_frozen = graph_util.convert_variables_to_constants(session, graphdef_inf, output)
graph_io.write_graph(graphdef_frozen, save_pb_dir, save_pb_name, as_text=save_pb_as_text)
return graphdef_frozen
K.clear_session()
K.set_learning_phase(0)
model = load_model('model.h5')
session = K.get_session()
freeze_graph(session, [out.op.name for out in model.outputs], save_pb_dir='.')
rm -rf openvino
python3 $INTEL_OPENVINO_DIR/deployment_tools/model_optimizer/mo_tf.py \
--input_model frozen_model.pb \
--input_shape [1,224,224,3] \
--output_dir openvino