简体   繁体   English

如何优化预训练的 tensorflow CNN model 以减少过拟合并提高假人脸检测的整体准确度

[英]How to optimize pretrained tensorflow CNN model in order to reduce overfitting and improve overall accuracy for fake face detection

vgg19_net = VGG19(input_shape = (200,200,3), include_top = False, weights = 'imagenet')

model_vgg19 = Sequential()
model_vgg19.add(vgg19_net)

model_vgg19.add(Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_uniform'))
model_vgg19.add(BatchNormalization())

model_vgg19.add(Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_uniform'))
model_vgg19.add(BatchNormalization()) 

model_vgg19.add(Conv2D(512, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_uniform'))
model_vgg19.add(BatchNormalization())
model_vgg19.add(MaxPooling2D())

model_vgg19.add(Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_uniform'))
model_vgg19.add(BatchNormalization())
model_vgg19.add(MaxPooling2D())

model_vgg19.add(Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_uniform'))
model_vgg19.add(BatchNormalization()) 


model_vgg19.add(Flatten())
model_vgg19.add(Dense(128, activation = 'relu', kernel_initializer = 'he_uniform'))
model_vgg19.add(Dense(1, activation = 'sigmoid'))

model_vgg19.compile(loss='binary_crossentropy',optimizer=Adam(lr=1e-5), metrics=['accuracy'])
model_vgg19.summary()

Above is my python code wherein I am trying to add layers to a pre-trained VGG19 model.以上是我的 python 代码,其中我正在尝试向预训练的 VGG19 model 添加层。 I have a dataset of real and fake faces and it's a classification question.我有一个真实面孔和虚假面孔的数据集,这是一个分类问题。 I have normalized pixel values (between 0 and 1) for all images and I am using 80% as training data and 20% as validation data.我已经对所有图像的像素值(0 到 1 之间)进行了标准化,我使用 80% 作为训练数据,20% 作为验证数据。 I am currently getting an accuracy of 95-96% on validation but on my test set I am only getting around 91-92% accuracy.我目前在验证上的准确度为 95-96%,但在我的测试集上,我的准确度只有 91-92% 左右。 I am new to DL and still learning how to pre-process face images and build effective models.我是 DL 新手,仍在学习如何预处理人脸图像和构建有效模型。 Please let me know if you see any abnormalities in my VGG19 implementation.如果您在我的 VGG19 实现中发现任何异常,请告诉我。 I have used image augmentation as well but it hasn't proven to be useful.我也使用了图像增强,但它并没有被证明是有用的。 Please let me know how I can make this question better since I am new to SO.请让我知道如何使这个问题变得更好,因为我是 SO 新手。 Also, the dataset is confidential so I cant share that.另外,数据集是机密的,所以我不能分享。 Sorry?对不起? Are there any pre-processing techniques I can use on my input images to better train my model?我可以在输入图像上使用任何预处理技术来更好地训练我的模型吗?

I don't see any issues in your code.我在您的代码中没有看到任何问题。 To improve this:- You Can Add Dropout To Reduce OverFitting , You Can Also Try To Use A ResNet Or A EfficientNet Version (Which Are Better At FakeFace Detection Than VGG);为了改善这一点:- 您可以添加 Dropout 以减少OverFitting ,您也可以尝试使用 ResNet 或 EfficientNet 版本(在 FakeFace 检测方面比 VGG 更好); Most Of All, You Can Toy With The HyperParameters;最重要的是,您可以玩弄超参数; Your LR is pretty low;你的LR很低; Try Increasing It.. If U want advanced techniques, you can try Multiple Outputs Or Use Image Segmentation(It is highly unlikely to help increase your accuracy but multiple outputs might).尝试增加它。如果你想要先进的技术,你可以尝试多个输出或使用图像分割(它不太可能帮助提高你的准确性,但多个输出可能)。

PS I recently worked on a similar dataset and managed to get 98% accuracy on the test set. PS 我最近研究了一个类似的数据集,并设法在测试集上获得了 98% 的准确率。 ( I Used EffNetB2 ) (我用过EffNetB2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM