Is it possible to retrain googles inception model with one class? - machine-learning

I would like to train this beautiful model to recognize only one type of images. To be clear at the end having the model capable of telling if the new image is part of that class or no. Thank you very much for your help.

You should keep in mind is that when you want to recognize a "dog" for example you need to know what is NOT a "dog" as well. So your classification problem is a two class problem and not one class. Your two classes will be "My Type" and "Not My Type".
About retraining your model, yes it is possible. I guess you use a model pretrained on Imagenet Dataset. There is two cases : If the classification problem is close (for example if your "type" is a class from Imagenet) you can just replace your last layer (replace Fully connected 1x1000 by FC 1x2) and retrain on this layer. If the problem is not the same you may want to retrain more layers.
It also depends on the number of Samples you have for your retrain.
I hope it helps or clarifies your question.

Is it possible to retrain googles inception model with one class?
Yes. Just remove the last layer, add a new layer with one (or two) nodes and train it on your new problem. This way you keep general features learned on the (probably bigger) image net dataset.

Related

Evaluation of generative models like variational autoencoder

i hope everyone is doing well
I need some help with generative models.
So im working on a project where the main task is to build a binary classification model. In the dataset which contains 300000 sample and 100 feature, there is an imbalance between the 2 classes where majority class is too much bigger than the minory class.
To handle this problem, i'm using VAE (variational autoencoders) to solve this problem.
So i started training the VAE on the minority class and then use the decoder part of the VAE to generate new or fake samples that are similars to the minority class then concatenate this new data with training set in order to have a new balanced training set.
My question is : is there anyway to evalutate generative models like vae, like is there a way to know if the data generated is similar to the real one ??
I have read that there is some metrics to evaluate generated data like inception distance and Frechet inception distance but i saw that they have been only used on image data
I wanna know if i can use them too on my dataset ?
Thanks in advance
I believe your data is not image as you say there are 100 features. What I believe that you can check the similarity between the synthesised features and the original features (the ones belong to minority class), and keep only the ones with certain similarity. Cosine similarity index would be useful for this problem.
That would be also very nice to check a scatter plot of the synthesised features with the original ones to see if they are close to each other. tSNE would be useful at this point.

Which deep learning model to use for capturing minor features in a image?

I have class which has slightly different features from the other class:
ex - This image has buckle in it (consider it as a class) https://6c819239693cc4960b69-cc9b957bf963b53239339d3141093094.ssl.cf3.rackcdn.com/1000006329245-822018-Black-Black-1000006329245-822018_01-345.jpg
But This image is quite similar to it but has no buckle :
https://sc01.alicdn.com/kf/HTB1ASpYSVXXXXbdXpXXq6xXFXXXR/latest-modern-classic-chappal-slippers-for-men.jpg
I am little confused about which model to use in these kind of cases which actually learns pixel to pixel values.
Any thoughts will be appreciable.
thanks !!
I have already tried Inception,Resnet etc models.
With a less volume train data (300-400 around each class) can we reach a good recall/precision/F1 score.
You might want to look into transfer learning due to the small dataset, what you can do is use a transferred ResNet model to work as a feature extractor and try a YOLO(You only look once) algorithm on it, look through each window(Look Sliding window implementation using ConvNets) to obtain a belt buckle and based on that you can classify the image.
Based on my understanding of your dataset, to do the above approach though you will need to re-annotate your dataset as per the requirements of YOLO algorithm.
To look at an example of the above approach, visit https://mc.ai/implementing-yolo-using-resnet-as-feature-extractor/
Edit If you have XML annotated Dataset and need to convert it to csv to follow the above example use https://github.com/datitran/raccoon_dataset
Happy modelling.

Should a deep-learning based image classifier include a negative class

I am building a image classifier similar to alexnet(https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks).
I have 6 categories [people,car,bikes,animals,hydroplanes,boats]. So right now if I give an object that doesn't not belong to the above mentioned classes it gets classified to either of the classes with some probability.
To increase the accuracy is it wise to add more classes or add a negative class?
And if I had to add a negative class what kind of data would I train it on?
Thank You
Think about what you really want to produce at the end.
You need an algorithm that tells you wether the image you passed is a car, bike, animal, person, hydroplane, boat.
Do the user is supposed to pass an image that represents something else ? If so, you can add a "other" class.
Well, it depends on what kind of classifier you want to build and available training data.
If you have enough training data for a new class, e.g., train, you can easily add a new class. It is quite straightforward. But the problem remains, if some new object appears at input then what to do....
I think your question is, how to handle a situation when an object(which is not the training set) is presented to the network. In such cases adding a negative class is quite complex as network need enough and clear training data for negative class as well. So one way to deal with this situation is to put a check on the output probabilities. If no training class get say 70% of output probability than classify the input as ambiguous or negative class.

Image classification - adding new classes to existing model

I am using the classical SIFT - BOW - SVM for image classification. My classifiers are created using the 1vsAll paradigm.
Let's say that I currently have 100 classes.
Later, I would like to add new classes OR I would like to improve the recognition for some specific classes using additional training sets.
What would be the best approach to do it ?
Of course, the best way would be to re-execute every steps of the training stage.
But would it make any sense to only compute the additional (or modified) classes using the same vocabulary as the previous model, in order avoid to recompute a new vocabulary and train again ALL the classes ?
Thanks
In short - no. If you add new class it should be added to each of the "old" classifiers so "one vs. all" still makes sense. If you assume that new classes can appear with time consider using one class classifiers instead, such as one-class SVM. This way once you get new samples for a particular class you only retrain a particular model, or add a completely new one to the system.
Furthermore, for large number of classes, 1 vs all SVM works quite badly, and one-class approach is usually much better.

Can an instance be discarded when one/several feature-values are outside of range?

I'm building a recognizer of antibodies in blod-cells images. It is based on libsvm. The prototype works well when it comes to recognize an instance which belongs to one of trained classes.
But when I give any image even not containing blod-cells (e.g. Microscope had bad offset/focus), it still suggests one of the classes known by model.
I first considered to implement class "Unknown" but I'm affraid training it with all the noise images would make the model performance worse.
So my idea is to check, if one/several feature(s) of an instance to be recognized is out of value-range and discard it.
Is it a good method?
If yes, how should the cut-off be selected (e.g. in terms of standard deviations)?
Thank you very much!
In problems with "possible non class samples" the most obvious solution seems to be create a one-class SVM (outlier detection algorithm) in one of two ways:
Train two one-class SVMs (oner per class) and discard samples marked by both models as "outliers"
Train one one-class SVM on the whole dataset (instances of both classes) and discard data marked as outlier
Suggested approach with "out of range check" is good as long as there is an obvios threshold value - as you are asking here what would be the best choice - it means that it is not a good way. If you cannot (as an expert) figure out it by yourself, it seems much better and safer option to train outlier detection method as suggested before, which will actualy do the same thing, but in the automatic fashion (as it will find rules for discarding "bad data" without training on any "bad images").

Resources