MrtnMndt / OpenVAE_ContinualLearning

Open-source code for our paper: Unified Probabilistic Deep Continual Learning through Generative Replay and Open Set Recognition
https://doi.org/10.3390/jimaging8040093
MIT License
61 stars 12 forks source link

Questions on the Outlier Detection #7

Open limzh123 opened 2 years ago

limzh123 commented 2 years ago

Hi, I have a question about outlier detection.

After executing the OpenVAE, can we know which image is the outlier?

I really appreciate any help you can provide.

MrtnMndt commented 2 years ago

Hi @limzh123 ,

Yes, you can load your trained model with the eval_openset.py script, which will estimate outliers on the test examples of the dataset which has been trained on and several other datasets. You will then get percentages etc. back.

I'm not sure if I understand correctly, but it may be that you are asking for a function that predicts whether a single image is an outlier or not? Unfortunately, we have not included such a function right now, as the main goal of the paper was on the continual training with open set recognition, and not the evaluation of single images.

In principle, you should be able to craft this yourself quite easily though. Given your pre-trained model, you can basically take the first half of the eval_openset script and get your Weibull distributions/models. Then you can do the steps from lines 193 to 202 in a simplified form: get z values for your image, calculate distance, call the Weibull models to get the outlier probability. In other words, you can do the steps inside these lines/functions, but remove all of the loop that currently do this for an entire dataset/many mini.batches.

Alternatively: if my understanding is correct you pretty much want the 7 lines in https://github.com/MrtnMndt/OpenVAE_ContinualLearning/blob/2cca59334c8993f96af15daf70d99ba89fea003f/lib/Datasets/incremental_dataset.py#L343 but replace the "sample z" part with a value from the encoder for your image and then do the distance + outlier calculations in the lines below.

Kindly let me know if this was your question.

limzh123 commented 2 years ago

Hi, yea this was my question. Thanks for your explanation.