Which pre-trained model works best for disaster classification

时间:2019-02-18 00:47:22

标签: machine-learning deep-learning computer-vision training-data transfer-learning

I'm new to deep learning, I want to build a model that predicts the type of disaster (flood, Fire, Infrastructure damage) from a giving picture. I want to proceed with transfer learning and I'm not sure which model would give me the best result.

I tried using building a cnn model from scratch but the I got a test accuracy = 70% which is low.

model code is below :

num_classes=3
model = Sequential()
model.add(Conv2D(64, kernel_size=(3, 3),
             activation='relu',
             input_shape=(512,512,3)))
model.add(Conv2D(128, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(256, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(num_classes, activation='softmax'))

model.compile(loss=keras.losses.categorical_crossentropy,
          optimizer=keras.optimizers.Adadelta(),
          metrics=['accuracy'])

kf=KFold(n_splits=10 ,shuffle=True)

for train_index, test_index in kf.split(X):
   print("Folding")
   x_train, x_test = X[train_index], X[test_index]
   y_train, y_test = y[train_index], y[test_index]

   y_train = to_categorical(y_train, num_classes)
   y_test = to_categorical(y_test, num_classes)

   model.fit(x_train, y_train,
          batch_size=batch_size,
          epochs=epochs,
          verbose=1,
          validation_data=(x_test, y_test))
   score = model.evaluate(x_test, y_test, verbose=0)
   print('Test loss:', score[0])
   loss.append(score[0])
   print('Test accuracy:', score[1])
   acc.append(score[1])

PS : X is a numpy array with shape (3000,512,512,3) and Y is a numpy array with shape (3000,1) with values {0,1,2} for each class

1 个答案:

答案 0 :(得分:0)

我在resnet18模型中使用转移学习,三个类别中的每一个仅包含100张图像,因此准确率达到了99%。我认为这应该可以解决您的问题。