I’m training images for classification but training and validation accuracy is always 100 percent.
I’ve used pretrained models, Custom models also techniques like data augmentation, resizing scaling.
But every time results same.
At testing model predicting same class for all new images.
Welcome to the Tensorflow Team!
I’ve used pretrained models, Custom models also techniques like data augmentation, resizing scaling.
Can you elaborate a bit more on your model architecture and data set? Please share the standalone code to troubleshoot the problem reported above.
I’ve used tflite-model-maker with efficient-lite also with mobilenet, custom models also transfer learning on a person classification.
Problem I want to solve is attendance system through image classification. I’ve dataset of 100 images of each person.
How is the data is split into training and validation? What is the cardinality of the dataset in training and validation? also, i would like to confirm that validation data has not been exposed to the model during training?
Can you please answer the above queries? and if possible please share colab gist to debug issue.
You could check the train_model() function in my colab sheet
training & validation data split was variable like 80/20-70/30 also cardinality was also variable I was testing different scenarios. For the question “i would like to confirm that validation data has not been exposed to the model” you could check my sheet
Usually model will be trained with both negative and positive classes. But from your code i observed only positive sample.
e.g: If the task is to identify x
person then x
will be the positive sample and every other sample will be labelled as a negative sample. Thank you!
I also trained with multiple classes but for every testing class, it gives the same output like the 386 user class for every test class
Can you try to increase the sample count for every class and let us know?
Like an increase in the number of images?
Like an increase in the number of images?
Yes.
Ok let me try that. and thanks for the help
By the way how much data i should increase? At this time I have about 105 images per class
One more thing if I train the model with multiple classes it predicts very well for the test accuracy.
but when I introduce new data like some new images of the same person it predicts wrong
or when I introduces new images like shoe or tree it predict that with present no of classes.
I don’t know what could be the problem
By the way how much data i should increase?
There is no hard and fast rule. Usually more the data, better the results for generalization.
if I train the model with multiple classes it predicts very well for the test accuracy.
Since the model is trained on different classes, it is able to classify test images well
when I introduce new data like some new images of the same person it predicts wrong
We should make sure to feed all types of images of a person during training
when I introduces new images like shoe or tree it predict that with present no of classes
Yes, this is due to the classification labels given during the training.
I increased the dataset to 450 images per class but didn’t make any changes.
Actually, I want to make a facial attendance system of a person through images.
Should I change my problem from image classification to object detection?
Yes, this is due to the classification labels given during the training.
But I didn’t introduce labels for trees or shoes but it’s giving a class of a person against them.
From your colab gist, you are training the model using one class(i.e 386). In that case the model learns only images belong to that class, which constitutes class imbalance (i.e that is why 100% training and validation). Please refer screenshot below
For the model to learn better we need to train using images from all the classes.
To debug your issue, we required following details
- How are you labeling?
- How many classes?
- Folder structure of
user_training
- How is the data used for training?
- I’m not labeling, I’m following directory hierarchy as per documentation. It assigns a folder name as the image’s label like the 386 folder name for all images inside the 386 folder.
- data = DataLoader.from_folder(“/content/usertraining”)
-
I’m using 2 classes with exactly 100 images.
-
I’m following this pattern from docs. Under user training all user folders
user_training
44
55 -
I’ve used 80/10/10 for training.