-
Notifications
You must be signed in to change notification settings - Fork 20
Home
Katsuya Hyodo edited this page Jun 1, 2019
·
54 revisions
Environment
- Tensorflow v1.13.1
Reference article
https://github.com/NobuoTsukamoto/edge_tpu_mnist/blob/master/train/MNIST_fully_connected_feed.ipynb
mkdir dataset;cd dataset
curl -sc /tmp/cookie "https://drive.google.com/uc?export=download&id=1llUu6071hd0QY2DY5vs_7VPaceI7EVst" > /dev/null
CODE="$(awk '/_warning_/ {print $NF}' /tmp/cookie)"
curl -Lb /tmp/cookie "https://drive.google.com/uc?export=download&confirm=${CODE}&id=1llUu6071hd0QY2DY5vs_7VPaceI7EVst" -o train2017.zip
unzip train2017.zip
rm train2017.zip
curl -sc /tmp/cookie "https://drive.google.com/uc?export=download&id=1bB8M-WG2LJwmB6YpLMsxUTWwIX3BwYkr" > /dev/null
CODE="$(awk '/_warning_/ {print $NF}' /tmp/cookie)"
curl -Lb /tmp/cookie "https://drive.google.com/uc?export=download&confirm=${CODE}&id=1bB8M-WG2LJwmB6YpLMsxUTWwIX3BwYkr" -o val2017.zip
unzip val2017.zip
rm val2017.zip
curl -sc /tmp/cookie "https://drive.google.com/uc?export=download&id=1P5pir4LVhev_S1Yvu_K3q_hGERAcFpg6" > /dev/null
CODE="$(awk '/_warning_/ {print $NF}' /tmp/cookie)"
curl -Lb /tmp/cookie "https://drive.google.com/uc?export=download&confirm=${CODE}&id=1P5pir4LVhev_S1Yvu_K3q_hGERAcFpg6" -o annotations_trainval2017.zip
unzip annotations_trainval2017.zip
rm annotations_trainval2017.zip
cd ..
mkdir -p models/train
mkdir -p models/pretrained/mobilenet_v2_1.4_224;cd models/pretrained/mobilenet_v2_1.4_224
wget https://storage.googleapis.com/mobilenet_v2/checkpoints/mobilenet_v2_1.4_224.tgz
tar -xzvf mobilenet_v2_1.4_224.tgz;rm mobilenet_v2_1.4_224.tgz
unsupported operand type(s) for +: 'NoneType' and 'float'
measures
sed -i s/"(slim.batch_norm,): {'center': True, 'scale': True, 'is_training': False},"/"(slim.batch_norm,): {'center': True, 'scale': True},"/ tf_pose/mobilenet/mobilenet_v2.py
cd ../../..
python3 tf_pose/train2.py \
--model=mobilenet_v2_1.4 \
--datapath=dataset/annotations/ \
--imgpath=dataset/ \
--batchsize=1 \
--gpus=1 \
--maxepoch=1 \
--lr=0.001 \
--quantdelay=0
sed -i s/"(slim.batch_norm,): {'center': True, 'scale': True},"/"(slim.batch_norm,): {'center': True, 'scale': True, 'is_training': False},"/ tf_pose/mobilenet/mobilenet_v2.py
python3 model_compression_quantize.py
sed -i s/"(slim.batch_norm,): {'center': True, 'scale': True, 'is_training': False},"/"(slim.batch_norm,): {'center': True, 'scale': True},"/ tf_pose/mobilenet/mobilenet_v2.py
python3 freeze_graph.py \
--input_graph=models/train/test/model-finalquant.pb \
--input_checkpoint=models/train/test/model-finalquant-1 \
--output_graph=models/train/test/model-finalquantfrozen.pb \
--output_node_names=Openpose/concat_stage7 \
--input_binary=True \
--clear_devices=True
graph_image - model-finalquantfrozen.pb
mkdir -p models/train/test/tflite
tflite_convert \
--output_file="models/train/test/tflite/output_tflite_graph.tflite" \
--graph_def_file="models/train/test/model-finalquantfrozen.pb" \
--inference_type=QUANTIZED_UINT8 \
--input_arrays="image" \
--output_arrays="Openpose/concat_stage7" \
--mean_values=128 \
--std_dev_values=128 \
--input_shapes=1,368,432,3 \
--change_concat_input_ranges=false \
--allow_nudging_weights_to_use_fast_gemm_kernel=true
edgetpu_compiler \
--out_dir models/train/test/tflite \
models/train/test/tflite/output_tflite_graph.tflite
git clone -b v1.13.1 https://github.com/tensorflow/tensorflow.git
cd tensorflow
git checkout -b v1.13.1
sudo bazel run tensorflow/lite/tools:visualize -- \
${HOME}/git/MobileNetV2-PoseEstimation/models/train/test/tflite/output_tflite_graph_edgetpu.tflite \
${HOME}/git/MobileNetV2-PoseEstimation/models/train/test/tflite/model_viz.html