Clone Code: git clone https://github.com/sidhartha-roy/anomaly-detection.git
Pre-trained VGG16 convolution layers + new classification layers added. Portion of the convolution layers are frozen.
Color jitter, Random Vertical Flip/ Horizontal Flip/ Rotation. You can try testing the model by training it after changing these parameters.
For data preprocessing please follow instructions in the preprocessing folder.
- setup a virtual environment named anomaly
conda create -n anomaly python=3.6
- Activate the environment:
conda activate anomaly
- Install PyTorch:
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
- Install python requirements
pip install -r requirements.txt
- Make sure the directory
./preprocessing/data
exists and contains the/normal
and/anomaly
folders with images. - Open the file
config.py
and setup the parameters for training and testing. - Split the data set into train/validation/test folders:
python3 split.py
- Train the model:
python3 run_training.py
This command downloads vgg16 model, modifies it, creates the dataloader, trains the model, and stores the trained model and history of training in folder/pretrained
. Loss history curve is displayed (remember to close window to continue). - Test the accuracy of the model:
python3 test.py
More model performance features such as ROC and AUC curves can be plotted easily.
To play with the code please use the notebook Anomaly_Detection.ipynb