# 物体検出のtfliteモデル比較 ###### tags: `ID` ## やったこと * https://dev.classmethod.jp/machine-learning/tensorflow-lite-with-coral-usb-accelerator-on-mac/ を参考に、mac book proで`tflite`モデルを動かせる環境構築を行った。 * `mobilenet-ssd-v2`modelと`yolo-v3`modelの速度と精度を比較した。 ## メモ * 基本的には上記サイトの情報に沿って進めれば環境構築が可能。 * ただし、以下の点に注意 * コマンドライン引数で指定するモデルの名前は`models/mobilenet_ssd_v2_coco_quant_postprocess.tflite`にする(`_edgetpu`とついているものはtpu向けに変換されている) * こちらのコード(https://github.com/google-coral/tflite/blob/ce557abbbf2c135a4ede052a8e75f3af6eb39d6f/python/examples/detection/detect_image.py#L55)を以下のように変更する(元のコードは`edgetpu`を使うことが前提になっている) ```{python} def make_interpreter(model_file): model_file, *device = model_file.split('@') return tflite.Interpreter(model_path=model_file) ``` * 実行の流れ(自分用メモ) ```{bash} $ cd i-d/tflite-coral-example/ $ source ./venv37/bin/activate $ cd edgetpu_runtime/google-coral/tflite/python/examples/detection $ python detect_image.py --model models/mobilenet_ssd_v2_coco_quant_postprocess.tflite --labels models/coco_labels.txt --input images/img4.JPG ``` * `yolo-v3`を動かす際は以下のようなコマンドを実行する。 ```{bash} $ cd i-d/tflite-coral-example/ $ source ./venv37/bin/activate $ cd tensorflow-lite-YOLOv3 $ python tflite_example.py -i example.jpg ``` ## 所感 * 量子化すると`yolo-v3`も`mobilenet-ssd-v2`もあんまり精度が変わらないかもしれない。 * それでいて精度は10倍ぐらい違う。