[UL] Abnormaly detection
UL stands for Unsupervised Learning.
In this application, we use the PatchCore algorithms to learn the good-only dataset. Then we use the K-Nearest Neighbors (KNN) algorithms to separate the newly seen good and ng data.
1. Prepare your dataset
# your dataset structure should be like this
data/
-train/
-good/
-*.jpg
-test/
-good/
-*.jpg
-ng/
-*.jpg
Notes
The number of train data should be > 10 items. If it is <10 items, please rotated the images to create more.
2. Usages
Training
Go to /projects/indad-holes
Execute this command:
python train.py --model_type spade --data_dir "<PATH_TO_TRAIN_FOLDER>"
Note
PATH_TO_TRAIN_FOLDER
should be one-level above the image files, i.e. ../data/train
, not ../data/train/good
The model will be saved into results
folder.
Testing
Go to /projects/indad-holes
Execute this command:
python predict.py --model_type spade --data_dir "<PATH_TO_TEST_FOLDER>" --threshold 1
Note
PATH_TO_TRAIN_FOLDER
should be where the image files are, i.e. ../data/train/good
Result images will be save into results
folder.
3. Improve the performance
If the prediction is not good, please consider either tuning the threshold or adding more data