1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

物体検出の学習済みモデル使ってみた

Last updated at Posted at 2021-09-09

学習済みモデルのダウンロード

openimagev4と呼ばれるデータセットで訓練したSSD(Single Shot MultiBox Detector)というモデルを使ってみました

openimagev4

600種類のクラスはここから確認できます
https://storage.googleapis.com/openimages/2018_04/class-descriptions-boxable.csv

実際に使ってみる

https://tfhub.dev/google/openimages_v4/ssd/mobilenet_v2/1
圧縮されたフォルダを展開してロードするだけです。

modelpath = "./openimages_v4_ssd_mobilenet_v2_1" #"./faster_rcnn"
model = hub.load(modelpath).signatures['default']

入力はTensorです

def load_img(path):
  img = tf.io.read_file(path)
  img = tf.image.decode_jpeg(img, channels=3)
  return img

localpath = os.path.join(dpath, fname)
image = Image.open( localpath )
tfimg = load_img( localpath )
converted_img  = tf.image.convert_image_dtype(tfimg, tf.float32)[ tf.newaxis, ... ]

result = model(converted_img)

検出結果

18084_02S.jpg

18084_02S.jpg_Car_97%_4cc9.jpg

速度と精度

速度だと
yolo > ssd > faster-rcnn
精度は
faster-rcnn > ssd > yolo
という認識です

480x270pxの画像を使って、faster-rcnnという精度重視のモデルと比較してみました

モデル/速度平均値(秒/枚) Geforce RTX 2080 Ti(7.5)
ssd 0.2
faster-rcnn 2

標準偏差は0.001程度でほぼ無視できます

時間あれば適合率も出しますね

残念なとこ

転移学習はできないみたいです。
https://github.com/pythonlessons/TensorFlow-2.x-YOLOv3

そーす

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?