Open4
Mobile SpineNet-49 の tflite 変換試行
docker run --gpus all -it --rm \
-v `pwd`:/home/user/workdir \
ghcr.io/pinto0309/openvino2tensorflow:latest
git clone https://github.com/tensorflow/models.git && cd models
git checkout 77bf83b493617df6c5cd35b8d8cf495944161d99
pip install tf-models-official
export PYTHONPATH=$PYTHONPATH:${PWD}
cd official/vision/serving/
python3 export_saved_model.py \
--experiment=retinanet_mobile_coco \
--export_dir=saved_model \
--checkpoint_path=ckpt-277200 \
--config_file=coco_spinenet49_mobile_tpu.yaml \
--batch_size=1 \
--input_type='image_tensor' \
--input_image_size='384,384'
saved_model_to_tflite \
--saved_model_dir_path saved_model/saved_model \
--input_shapes [1,384,384,3] \
--output_no_quant_float32_tflite
- Mobile SpineNet-49 - 384x384
I tried the params_override
option.
git clone https://github.com/tensorflow/models.git
cd models
git checkout 24ae1f51df065e38e89c3bda5e4a53448f40b426
cat <<EOF > ./override_param.yaml
task:
export_config:
cast_detection_classes_to_float: true
cast_num_detections_to_float: true
output_normalized_coordinates: true
model:
detection_generator:
apply_nms: true
tflite_post_processing:
max_classes_per_detection: 5
max_detections: 200
nms_iou_threshold: 0.5
nms_score_threshold: 0.1
use_regular_nms: false
use_cpu_nms: true
EOF
python3 official/vision/serving/export_saved_model.py \
--experiment=retinanet_mobile_coco \
--export_dir=./coco_spinenet49s_mobile \
--checkpoint_path=./vision_retinanet_spinenet49mobile/ckpt-277200 \
--config_file=official/vision/configs/experiments/retinanet/coco_spinenet49_mobile_tpu.yaml \
--params_override=./override_param.yaml \
--batch_size=1 \
--input_image_size=384,384 \
--input_type=tflite \
--log_model_flops_and_params
python3 official/vision/serving/export_tflite.py \
--experiment="retinanet_mobile_coco" \
--saved_model_dir=./coco_spinenet49s_mobile/saved_model \
--config_file=./coco_spinenet49s_mobile/params.yaml \
--tflite_path=./coco_spinenet49s_mobile/vision_retinanet_spinenet49mobile.tflite
ls -alh coco_spinenet49s_mobile/vision_retinanet_spinenet49mobile.tflite
-rw-r--r-- 1 root root 216M Mar 18 12:29 coco_spinenet49s_mobile/vision_retinanet_spinenet49mobile.tflite