「keras(tensorflow)でSegNet」
(https://qiita.com/uni-3/items/a62daa5a03a02f5fa46d)
を参考に記載されているコードをそのまま自分でも動かしてみようと
試みておりますが、実行するとメモリーのエラーがでてしまうため
下記を試みました。
(test.txt、train.txtを編集して読み込み画像を減らしてみましたが
やはりメモリーのエラーがでてしまいます)
試したこと:読み込み画像サイスを(360×480)から半分の(180×240)に変更
エラー:ValueError: total size of new array must be unchanged
下記のように画像の読み込みまでは動きますがモデルの作成でエラーが発生
いたします。
loading data...
..............................input data shape... (30, 180, 240, 3)
input label shape... (30, 43200, 12)
....................creating model...
Traceback (most recent call last):
これは、ダウンサンプリングの際に(180×240)→(90×120)→(45×60)→(22×30)と
なって、アップサンプリングの際に(22×30)→(44×60)→(88×120)→(176×240)と
サイズが元にもどっていないことが原因で、decoderの部分にZeroPaddingで
画像のサイズを調整すればいいということは理解しましたが、そのやり方(コード)が
わからずにおります。(44×60)のサイズをZeroPaddingで(45×60)にする方法を
ご教示いただけませんでしょうか。
その他のエラー回避方法があればそれでもありがたいですし、認識が間違って
おりましたらご指摘いただけるのも助かります。
使用しているコード部分を下記いたします。
Python
1def SegNet(input_shape=(360, 480, 3), classes=12): 2 img_input = Input(shape=input_shape) 3 x = img_input 4 # Encoder 5 x = Conv2D(64, (3, 3), padding="same")(x) 6 x = BatchNormalization()(x) 7 x = Activation("relu")(x) 8 x = MaxPooling2D(pool_size=(2, 2))(x) 9 10 x = Conv2D(128, (3, 3), padding="same")(x) 11 x = BatchNormalization()(x) 12 x = Activation("relu")(x) 13 x = MaxPooling2D(pool_size=(2, 2))(x) 14 15 x = Conv2D(256, (3, 3), padding="same")(x) 16 x = BatchNormalization()(x) 17 x = Activation("relu")(x) 18 x = MaxPooling2D(pool_size=(2, 2))(x) 19 20 x = Conv2D(512, (3, 3), padding="same")(x) 21 x = BatchNormalization()(x) 22 x = Activation("relu")(x) 23 24 # Decoder 25 x = Conv2D(512, (3, 3), padding="same")(x) 26 x = BatchNormalization()(x) 27 x = Activation("relu")(x) 28 29 x = UpSampling2D(size=(2, 2))(x) 30 x = Conv2D(256, (3, 3), padding="same")(x) 31 x = BatchNormalization()(x) 32 x = Activation("relu")(x) 33 34 x = UpSampling2D(size=(2, 2))(x) 35 x = Conv2D(128, (3, 3), padding="same")(x) 36 x = BatchNormalization()(x) 37 x = Activation("relu")(x) 38 39 x = UpSampling2D(size=(2, 2))(x) 40 x = Conv2D(64, (3, 3), padding="same")(x) 41 x = BatchNormalization()(x) 42 x = Activation("relu")(x) 43 44 x = Conv2D(classes, (1, 1), padding="valid")(x) 45 x = Reshape((input_shape[0] * input_shape[1], classes))(x) 46 x = Activation("softmax")(x) 47 model = Model(img_input, x) 48 return model
お手数をお掛けいたしますが、よろしくお願い申し上げます。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。