LoginSignup
10
12

More than 5 years have passed since last update.

ssd_kerasを試してみる

Last updated at Posted at 2018-10-20

環境

Mac
Anaconda 5.3
python 3.6.6
keras2
tensorflow 1.11.0

ssd_kerasを取得

$ git clone https://github.com/rykov8/ssd_keras.git

必要な物をinstall

opencv

$ conda install -c conda-forge opencv

あたりまえだけど、keras

$ conda install keras

動かしてみる

準備が整い、SSD.ipynbを上から順に実行していくと、下記の部分でエラーがでた。

input_shape=(300, 300, 3)
model = SSD300(input_shape, num_classes=NUM_CLASSES)
model.load_weights('weights_SSD300.hdf5', by_name=True)
bbox_util = BBoxUtility(NUM_CLASSES)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-dd64fe36fa33> in <module>
      1 input_shape=(300, 300, 3)
----> 2 model = SSD300(input_shape, num_classes=NUM_CLASSES)
      3 model.load_weights('weights_SSD300.hdf5', by_name=True)
      4 bbox_util = BBoxUtility(NUM_CLASSES)

~/github/ssd_keras/ssd.py in SSD300(input_shape, num_classes)
    256                              net['conv8_2_mbox_loc_flat'],
    257                              net['pool6_mbox_loc_flat']],
--> 258                             mode='concat', concat_axis=1, name='mbox_loc')
    259     net['mbox_conf'] = merge([net['conv4_3_norm_mbox_conf_flat'],
    260                               net['fc7_mbox_conf_flat'],

TypeError: 'module' object is not callable

Keras2に対応する

Kerasのversionが合っていないらしい。
Pull requestにKeras2に対応してくれている方がいたので、使わせて頂く。

$ git fetch origin pull/141/head:api_update_to_keras2
$ git branch -a
  api_update_to_keras2
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
$ git checkout api_update_to_keras2

もう一度動かしてみる

notebookを起動しなおして再実行してみると、今度は問題なし。
SSD.ipynbもいろいろ書き換わっていて問題なく動いた。
これを参考にしながら自分なりに何か作ってみたい。

ダウンロード.png

10
12
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
10
12