hcw-00 / PatchCore_anomaly_detection

Unofficial implementation of PatchCore anomaly detection
Apache License 2.0
320 stars 92 forks source link

how test my own dataset without groundtrouth? #7

Closed letmejoin closed 3 years ago

letmejoin commented 3 years ago

As described in title, the data from real world without GT_mask, but almost every algorithms need gt_mask to get roc_auc_score. Do you try to decide the threshold of anomaly score which higher than the threshold will be thought as anomaly ? Other than obtained the optim threshold from GT ? The problem confiused me all the time.

hcw-00 commented 3 years ago

Unfortunately, You have to slightly modify the code to make it work with your own dataset.

In the case of Image level anomaly classification, to obtain optimal threshold you should prepare datasets with two class. then you can calculate roc curve then you can try several methods to get optimal threshold (like max of Youden's J statistic).

On the other hand, generally it's hard to prepare pixel level anomaly GT. In this case, there is no way to get roc curve and optim threshold. I don't know but I would try checking distribution of normal pixel's score and setting threshold manually.

letmejoin commented 3 years ago

Unfortunately, You have to slightly modify the code to make it work with your own dataset.

In the case of Image level anomaly classification, to obtain optimal threshold you should prepare datasets with two class. then you can calculate roc curve then you can try several methods to get optimal threshold (like max of Youden's J statistic).

On the other hand, generally it's hard to prepare pixel level anomaly GT. In this case, there is no way to get roc curve and optim threshold. I don't know but I would try checking distribution of normal pixel's score and setting threshold manually.

Thks for your replay! Yes, the pixel-level threshold is the problem. I have an idea about the 3-sigma of the Gaussian distrabution of patches, but each patch has an only distribution. For how to use the infomation, I' m working on it ! Would you have advise?

hcw-00 commented 3 years ago

Sorry, I don't have great idea. But, as I said, If would try to check distribution of each pixel values of (normal) anomaly map.