Julian-Wyatt / AnoDDPM

CVPR Workshop paper - AnoDDPM: Anomaly Detection with Denoising Diffusion Probabilistic Models using Simplex Noise
https://julianwyatt.co.uk/anoddpm
MIT License
174 stars 28 forks source link

Some problems with running detection #18

Closed ZZZGGGG closed 11 months ago

ZZZGGGG commented 1 year ago

Hello author, when I run the detection code with in_channel==3, I encounter the following problem: Traceback (most recent call last): File "detection.py", line 958, in anomalous_metric_calculation() File "detection.py", line 231, in anomalous_metric_calculation fpr_simplex, tprsimplex, = evaluation.ROC_AUC(mask.to(torch.uint8), mse) File "/home/primary/4T_a/AnoDDPM-master/evaluation.py", line 81, in ROC_AUC return roc_curve(real_mask.detach().cpu().numpy().flatten(), square_error.detach().cpu().numpy().flatten()) File "/home/primary/anaconda3/envs/zg/lib/python3.7/site-packages/sklearn/metrics/_ranking.py", line 963, in roc_curve y_true, y_score, pos_label=pos_label, sample_weight=sample_weight File "/home/primary/anaconda3/envs/zg/lib/python3.7/site-packages/sklearn/metrics/_ranking.py", line 733, in _binary_clf_curve check_consistent_length(y_true, y_score, sample_weight) File "/home/primary/anaconda3/envs/zg/lib/python3.7/site-packages/sklearn/utils/validation.py", line 334, in check_consistent_length % [int(l) for l in lengths] ValueError: Found input variables with inconsistent numbers of samples: [65536, 196608]

My mask is (1,1,256,256,), but my mse is (1,3,256,256), and I get an error when calculating roc_auc, my argument is: { "img_size": [ 256, 256 ], "Batch_Size": 1, "EPOCHS": 3000, "T": 1000, "base_channels": 128, "beta_schedule": "linear", "channel_mults": "", "loss-type": "l2", "loss_weight": "none", "train_start": true, "lr": 1e-4, "random_slice": true, "sample_distance": 800, "weight_decay": 0.0, "save_imgs": false, "save_vids": true, "dropout": 0, "attention_resolutions": "16,8", "num_heads": 2, "num_head_channels": -1, "noise_fn": "simplex", "dataset": "leather", "channels":3 } Is there a problem with where I did it?

Julian-Wyatt commented 1 year ago

Hi,

As you list, your mask and image are of different dimensions; therefore I'd recommend converting your mask to a 3-channel image for this to work.

I originally wrote this code with grayscale in mind and therefore didn't scale it to colour.

ZZZGGGG commented 1 year ago

Hi,

As you list, your mask and image are of different dimensions; therefore I'd recommend converting your mask to a 3-channel image for this to work.

I originally wrote this code with grayscale in mind and therefore didn't scale it to colour.

Thank you so much for your advice. It worked