Image Classification model overfit - keras

I have an image classification dataset that has 1020 training and 1020 validation images and the test image has more than 4000 images. I build a custom model to classify I use augmentation and dropout to reduce overfit but this method is not working I also try different regularization methods but it overfits again. The model has almost 440 layers with several skip connections. What will be the suggestion in that case?

Related

How to improve validation accuracy in training convolutional neural network?

I am training a CNN model(made using Keras). Input image data has around 10200 images. There are 120 classes to be classified. Plotting the data frequency, I can see that sample data for every class is more or less uniform in terms of distribution.
Problem I am facing is loss plot for training data goes down with epochs but for validation data it first falls and then goes on increasing. Accuracy plot reflects this. Accuracy for training data finally settles down at .94 but for validation data its around 0.08.
Basically its case of over fitting.
I am using learning rate of 0.005 and dropout of .25.
What measures can I take to get better accuracy for validation? Is it possible that sample size for each class is too small and I may need data augmentation to have more data points?
Hard to say what could be the reason. First you can try classical regularization techniques like reducing the size of your model, adding dropout or l2/l1-regularizers to the layers. But this is more like randomly guessing the models hyperparameters and hoping for the best.
The scientific approach would be to look at the outputs for your model and try to understand why it produces these outputs and obviously checking your pipeline. Did you had a look at the outputs (are they all the same)? Did you preprocess the validation data the same way as the training data? Did you made a stratified train/test-split, i.e. keeping the class distribution the same in both sets? Is the data shuffles when you feed it to your model?
In the end you have about ~85 images per class which is really not a lot, compare CIFAR-10 resp. CIFAR-100 with 6000/600 images per class or ImageNet with 20k classes and 14M images (~500 images per class). So data augmentation could be beneficial as well.

Yolov3 - Concatenate output layers to speed up training

I am using Yolov3 in Pytorch and have got 5 classes. Each class consists of approx. 500 images and after 2.500 iterations I get an mAP of 0.80%. However, the training takes approx. 2 days and I am strongly wondering how to decrease the training time.
One idea is to take a pretrained yolov3 network weights file, concatenate the three output layers and use these layers for training.
What do you think of this idea? Or will this not work?
Thanks!

Use pre-trained ResNet 50 in Keras for images with 4 channels

Is there any way I can use the ImageNet weights for ResNet50 for my project which has images of shape (224,224,4)? The image has R,G,B,Y channels.
At the moment, I am simply using
model = ResNet50(include_top=True, weights=None, input_tensor=None, input_shape=input_shape, pooling=None, classes=num_classes)
Now, if I need to use the ImageNet weights, I need to always set the number of classes to 1000. I tried doing that, and then popping the last layer, and adding my own Dense(num_classes) layer. However, now, the number of channels is an issue.
Can anyone suggest a way to accommodate 4 channels in the model while using the ImageNet weights?

ImageNet test dataset for keras applications models

I have a model pretrained on ImageNet like this:
from keras.applications import resnet50
model = resnet50.ResNet50(weights='imagenet')
Is there any way to get test ImageNet dataset and their labels (which means data not used for training the above model)?
Original
Sadly ImageNet (from ILSVRC2012) never released the labels for the 100k images in the test dataset. You can use instead the 50k images from the Validation dataset, whose labels can be found in the Develpoment Kit (tasks 1 and 2).
You can download both the Validation images and the validation labels from http://www.image-net.org/challenges/LSVRC/2012/downloads
Updated!
There is an ImageNet Test set with 100k images available here, and although you cannot access the labels, you can instead predict the labels for all the images and submit your predictions for evaluation (top1, top5) here.
You can load a model with weights=None and download imagenet dataset.You can then split the dataset into train-test, train your model with train set and use test set for your purpose

VGG16 trained on grayscale imagenet

I have found the VGG16 network pre-trained on the (color) imagenet database (as .npy). Is there a VGG16 network pre-trained on a gray-scale version of the imagenet database available?
(The usual 'tricks' for using the 3-channel filters of the conv1.1 layer on the gray 1-channel input are not enough for me. I am looking at incremental improvements of the network performance, so I need to see how the transfer learning behaves when the pre-trained model was 'looking' at gray-scale input).
Thanks!
Yes, there's this one:
https://github.com/DaveRichmond-/grayscale-imagenet
Greyscale imagenet trained model, and also a version of it that's finetuned on X-rays. They showed that Imagenet performance barely drops btw.
#GrimSqueaker gave you the code of this paper : https://openaccess.thecvf.com/content_eccv_2018_workshops/w33/html/Xie_Pre-training_on_Grayscale_ImageNet_Improves_Medical_Image_Classification_ECCVW_2018_paper.html
However, the model trained in it is Inception v3 not VGG16.
You have two options:
Use a colored pre-trained VGG16 model and duplicate one channel to the three channels
Train your VGG16 model on the ImageNet grayscaled dataset.
You may find this link useful:
https://github.com/zzangho/VGG16_grayscale

Resources