- http://pypi.douban.com/simple —trusted-host pypi.douban.com numpy==1.17.5
tensorboard 使用方法
tensorboard —logdir=/home/lingzl/local_dataset_models/MobileDet-EdgeTPU">开始训练并将日志保存下来
nohup python object_detection/model_main.py \
—model_dir=/home/lingzl/local_dataset_models/MobileDet-EdgeTPU \
—pipeline_config_path=/home/lingzl/tfrecords/pipeline.config \
—sample_1_of_n_eval_examples=1 \
—alsologtostderr \
—num_train_steps=55000 \
> smartcar_log1.out &
#导出pb文件
INPUT_TYPE=image_tensor
PIPELINE_CONFIG_PATH=/home/lingzl/tfrecords/pipeline.config
TRAINED_CKPT_PREFIX=/home/lingzl/local_dataset_models/MobileDet-EdgeTPU/model.ckpt-55000
EXPORT_DIR=/home/lingzl/local_dataset_models/MobileDet-EdgeTPU/frozen
python object_detection/export_tflite_ssd_graph.py \
—input_type=${INPUT_TYPE} \
—pipeline_config_path=${PIPELINE_CONFIG_PATH} \
—trained_checkpoint_prefix=${TRAINED_CKPT_PREFIX} \
—output_directory=${EXPORT_DIR} \
—input_shape=’-1,320,320,3’
#frzeon冻结模型
python object_detection/export_tflite_ssd_graph.py \
—pipeline_config_path=/home/lingzl/tfrecords/pipeline.config \
—trained_checkpoint_prefix=/home/lingzl/local_dataset_models/MobileDet-EdgeTPU/model.ckpt-55000 \
—output_directory=/home/lingzl/local_dataset_models/MobileDet-EdgeTPU/frozen \
—add_postprocessing_op=true
#量化转化成8bit文件
tflite_convert \
—output_file=/home/lingzl/local_dataset_models/MobileDet-EdgeTPU/frozen/MobilenetDet_quant.tflite \
—graph_def_file=/home/lingzl/local_dataset_models/MobileDet-EdgeTPU/frozen/tflite_graph.pb \
—input_shapes=1,320,320,3 \
—input_arrays=normalized_input_image_tensor \
—output_arrays=’TFLite_Detection_PostProcess’,’TFLite_Detection_PostProcess:1’,’TFLite_Detection_PostProcess:2’,’TFLite_Detection_PostProcess:3’ \
—inference_type=QUANTIZED_UINT8 \
—mean_values=128 \
—std_dev_values=128 \
—default_ranges_min=0 \
—default_ranges_max=255 \
—change_concat_input_ranges=false \
—allow_custom_ops
转换uint8
bazel run -c opt tensorflow/lite/toco:toco — \
—input_file=/home/lingzl/local_dataset_models/MobileDet-EdgeTPU/frozen/frozen_graph.pb \
—output_file=/home/lingzl/local_dataset_models/MobileDet-EdgeTPU/frozen/model.tflite \
—input_shapes=1,320,320,3 \
—input_arrays=normalized_input_image_tensor \
—output_arrays=’TFLite_Detection_PostProcess’,’TFLite_Detection_PostProcess:1’,’TFLite_Detection_PostProcess:2’,’TFLite_Detection_PostProcess:3’ \
—inference_type=QUANTIZED_UINT8 \
—allow_custom_ops
#训练使用的pipeline.config文件
fine_tune_checkpoint: “/home/lingzl/tfrecords/uint8/model.ckpt”
from_detection_checkpoint: true
load_all_detection_checkpoint_vars: true
num_steps: 20000000
graph_rewriter {
quantization {
delay: 10000
weight_bits: 8
activation_bits: 8
}
}
#导出推理模型
INPUT_TYPE=image_tensor
PIPELINE_CONFIG_PATH=/home/frank/local_dataset/smartcar_dataset/models/ssd_mobilenet_v2_quant_test2/pipeline.config
TRAINED_CKPT_PREFIX=/home/frank/local_dataset/smartcar_dataset/models/ssd_mobilenet_v2_quant_test2/model.ckpt-17981
EXPORT_DIR=/home/frank/local_dataset/smartcar_dataset/models/ssd_mobilenet_v2_quant_test2/frozen
python object_detection/export_inference_graph.py \
—input_type=${INPUT_TYPE} \
—pipeline_config_path=${PIPELINE_CONFIG_PATH} \
—trained_checkpoint_prefix=${TRAINED_CKPT_PREFIX} \
—output_directory=${EXPORT_DIR} \
—input_shape=’-1,320,320,3’
命令行 安装 tensorflow环境包
pip install -i http://pypi.douban.com/simple —trusted-host pypi.douban.com numpy==1.17.5
tensorboard 使用方法
tensorboard —logdir=/home/lingzl/local_dataset_models/MobileDet-EdgeTPU