vgg16, inception v3 코드
https://github.com/sagarvegad/Video-Classification-CNN-and-LSTM-
Keras documentation: Video Classification with a CNN-RNN Architecture
vgg16 | inception v3 | |
---|---|---|
data | bring_data_from_directory() / ImageDataGenerator 사용 / train_generator , validation_generator / 5개 분류 / target_size = (224,224) , batch_size =128 | tran_df , test_df / crop_center_square(), load_video() / IMG_SIZE = 224 / BATCH_SIZE = 64 / epochs=10 / max_seq_length=20 / num_features=2048 |
모델 적용 | load_VGG16_model() / base_model=VGG16(weights='imagenet', include_top=False, input_shape=(224,224,3)) | build_feature_extractor() : feature_extractor= keras.applications.InceptionV3 (weights=”imagenet”, include_top=False, pooling=”avg”,input_shape(IMG_SIZE,IMG_SIZE,3)) |
extract_features_and_store(train_generator,validation_generator,base_model) |
vgg 16
## 데이터 셋 구성
def bring_data_from_directory():
datagen = ImageDataGenerator(rescale=1. / 255)
train_generator = datagen.flow_from_directory(
'train',
target_size=(224, 224),
batch_size=batch_size,
class_mode='categorical', # this means our generator will only yield batches of data, no labels
shuffle=True,
classes=['class_1','class_2','class_3','class_4','class_5'])
validation_generator = datagen.flow_from_directory(
'validate',
target_size=(224, 224),
batch_size=batch_size,
class_mode='categorical', # this means our generator will only yield batches of data, no labels
shuffle=True,
classes=['class_1','class_2','class_3','class_4','class_5'])
return train_generator,validation_generator
## 모델 로드
def load_VGG16_model():
base_model = VGG16(weights='imagenet', include_top=False, input_shape=(224,224,3))
print "Model loaded..!"
print base_model.summary()
return base_model