Open1

TensorFlow 2 Detection Model Zoo の CenterNet MobileNetV2_FPN_Keypoints_512x512 のサイズ変更エクスポート

PINTOPINTO

Ubuntu 20.04 x86_64

git clone https://github.com/tensorflow/models
cd models/research
protoc object_detection/protos/*.proto --python_out=.
export PYTHONPATH=$PYTHONPATH:${PWD}/..

480x640 に変更する場合は、pipeline.config の

    image_resizer {
      keep_aspect_ratio_resizer {
        min_dimension: 512
        max_dimension: 512
        pad_to_max_dimension: true
      }
    }

を

    image_resizer {
      fixed_shape_resizer {
        height: 480
        width: 640
      }
    }

に修正する

python3 object_detection/export_tflite_graph_tf2.py \
--pipeline_config_path ../../pipeline.config \
--trained_checkpoint_dir ../../checkpoint \
--output_directory ../.. \
--max_detections 10 \
--keypoint_label_map_path ../../label_map.txt \
--centernet_include_keypoints

* --ssd_use_regular_nms True はcenternetでは無視される

cd ../..

xhost +local: && \
  docker run --gpus all -it --rm \
    -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/openvino2tensorflow:latest

cd workdir

saved_model_to_tflite \
--saved_model_dir_path saved_model \
--output_no_quant_float32_tflite

tflite2tensorflow \
  --model_path model_float32.tflite \
  --flatc_path ../flatc \
  --schema_path ../schema.fbs \
  --output_pb \
  --optimizing_for_openvino_and_myriad

tflite2tensorflow \
  --model_path model_float32.tflite \
  --flatc_path ../flatc \
  --schema_path ../schema.fbs \
  --output_no_quant_float32_tflite \
  --output_weight_quant_tflite \
  --output_float16_quant_tflite \
  --output_integer_quant_tflite \
  --string_formulas_for_normalization 'data / 255.0' \
  --output_tfjs \
  --output_coreml \
  --output_tftrt \
  --output_onnx \
  --onnx_opset 11 \
  --output_openvino_and_myriad