Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Project #1

Open
nabinabila opened this issue May 3, 2021 · 1 comment
Open

Use Project #1

nabinabila opened this issue May 3, 2021 · 1 comment

Comments

@nabinabila
Copy link

nabinabila commented May 3, 2021

Hello, I wanna use the project, how could i run it and have models results ( AUC) in Colab ?

@antoine-spahr
Copy link
Owner

Hi @nabinabila,

Thanks for your interest in our work !

We haven't made a clean callable function for our method since we have evaluated its capabilities on a specific dataset (the MURA dataset). If you wish to exploit the code provided here, you'll have few elements (from the module src) to put together for your specific case. I'll try to list explicit there (You can find the scripts for our experiment at Code/scripts/Contrastive/CDMSAD_scripts.py together with the JSON config_file).

  1. Our method is coded in the class CDMSAD at Code/src/models/CDMSAD.py. This class provides all the methods necessary to train and evaluate our approach (please reefer to the scripts Code/scripts/Contrastive/CDMSAD_scripts.py for the sequence and how to use it). You can initialize this class with your own architecture but note that your networks nn.Modules (repr_netand AD_net) should have a nn.Module named encoder as attributes that represents the part of the architecture that is transferred between the two tasks (see the class Encoder in Code/src/models/networks/Networks.py for an example based on the ResNet18 architecture).

  2. If you wish to use a different dataset than in our paper, you should implement your own pytorch dataset for the contrastive training and for the anomaly detection task (see Code/src/datasets/MURADataset.py for example). Note that the method uses semi-supervised labels to decide which sample to use and how. The semi-supervised labels are defined as : 0 -> unknown sample (assumed to come from the normal distribution) , 1 -> known normal samples , -1 -> known abnormal samples. For the whole train-loop to work, your datasets must return the same values as our dataset, but some of those may not be useful for your case (just replace them with None when returning the values from your dataset's getitem() method). In the contrastive dataset, the ones that are mandatory are the two images version and the sample index. In the AD_dataset the mandatory outputs are the image, the label (for evaluation), the semi-supervised label, and the sample index (the mask is not mandatory).

  3. To get the validation or test AUC from the CDMSAD object, you should call the evaluate_AD(your_valid_dataset, batch_size=..., n_job_dataloader=..., device='cuda', set='valid') method and you can then access the AUC value from the attributes results['valid']['AUC'].

I am sorry if the use of our code is not straight forward, but I hope I managed to help you make sense of it.

Cheers,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants