AnilOsmanTur / video_anomaly_diffusion

[ICIP 2023] Exploring Diffusion Models For Unsupervised Video Anomaly Detection
11 stars 1 forks source link

found some bugs #5

Open zuiwomeirenxi opened 6 months ago

zuiwomeirenxi commented 6 months ago

The first error: Traceback (most recent call last): File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\train_ano.py", line 371, in main() File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\train_ano.py", line 367, in main main_objective(config, args) File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\train_ano.py", line 110, in main_objective train_set = feature_dataset.ClipDataset( TypeError: ClipDataset.init() got an unexpected keyword argument 'normals' The second error occurred when I commented out 'normals=False': Traceback (most recent call last): File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\train_ano.py", line 371, in main() File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\train_ano.py", line 367, in main main_objective(config, args) File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\train_ano.py", line 128, in main_objective feat, label = train_set[0] ValueError: too many values to unpack (expected 2) I modified 'feat, label = train_set[0]' to 'feat, label,, = train_set[0]' which led to the third error: Traceback (most recent call last): File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\train_ano.py", line 371, in main() File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\train_ano.py", line 367, in main main_objective(config, args) File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\train_ano.py", line 149, in main_objective gcl_model = K.models.GCLModel( AttributeError: module 'k_diffusion.models' has no attribute 'GCLModel'. Did you mean: 'GVADModel'? So, I changed gcl_model = K.models.GCLModel( feat_size, ) to gcl_model = K.models.GVADModel( feat_size, ) Continuing, I encountered the fourth error: Traceback (most recent call last): File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\train_ano.py", line 371, in main() File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\train_ano.py", line 367, in main main_objective(config, args) File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\train_ano.py", line 282, in main_objective evaluate() File "D:\anaconda\envs\diffuser\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context return func(*args, kwargs) File "D:\anaconda\envs\diffuser\lib\contextlib.py", line 79, in inner return func(*args, *kwds) File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\train_ano.py", line 258, in evaluate genpreds, labels, , _ = K.evaluation.compute_eval_outs_aot(accelerator, sample_fn, test_dl) File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\k_diffusion\evaluation.py", line 21, in compute_eval_outs_aot feat = batch['data'] TypeError: list indices must be integers or slices, not str Then, I changed: feat = batch['data'] y = batch['label'] vid = batch['vid_id'] i = batch['idx'] to: feat = batch[0] y = batch[1] vid = batch[2] i = batch[3] Which resulted in the fifth error: Traceback (most recent call last): File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\train_ano.py", line 371, in main() File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\train_ano.py", line 367, in main main_objective(config, args) File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\train_ano.py", line 282, in main_objective evaluate() File "D:\anaconda\envs\diffuser\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context return func(args, kwargs) File "D:\anaconda\envs\diffuser\lib\contextlib.py", line 79, in inner return func(*args, **kwds) File "C:\DOWNLOAD\video_anomaly_diffusion-main\video_anomaly_diffusion-main\train_ano.py", line 261, in evaluate preds_auc = auroc(gen_preds, labels,task="binary") File "D:\anaconda\envs\diffuser\lib\site-packages\torchmetrics\functional\classification\auroc.py", line 470, in auroc return binary_auroc(preds, target, max_fpr, thresholds, ignore_index, validate_args) File "D:\anaconda\envs\diffuser\lib\site-packages\torchmetrics\functional\classification\auroc.py", line 174, in binary_auroc _binary_precision_recall_curve_tensor_validation(preds, target, ignore_index) File "D:\anaconda\envs\diffuser\lib\site-packages\torchmetrics\functional\classification\precision_recall_curve.py", line 135, in _binary_precision_recall_curve_tensor_validation _check_same_shape(preds, target) File "D:\anaconda\envs\diffuser\lib\site-packages\torchmetrics\utilities\checks.py", line 42, in _check_same_shape raise RuntimeError( RuntimeError: Predictions and targets are expected to have the same shape, but got torch.Size([138244, 512]) and torch.Size([138244]). I tried to recursively resolve these errors and ran this project on shanghaitech. The accuracy is around 0.79, but the AUC value remains around 0.5. This might be due to the changes I made in the code. So, I hope you could further improve the code. Your help is greatly appreciated. If you could refine the code, I would be extremely grateful."

kb1ooo commented 5 months ago

@zuiwomeirenxi would you mind posting your sequence of steps for training the models in this project? It's a little be difficult understanding the protocol.

zuiwomeirenxi commented 5 months ago

@zuiwomeirenxi would you mind posting your sequence of steps for training the models in this project? It's a little be difficult understanding the protocol.

Today is the Lunar New Year, and I'm on vacation. Can I reply to you after my vacation is over?

kb1ooo commented 4 months ago

@zuiwomeirenxi yes, of course! Enjoy your vacation!

kb1ooo commented 4 months ago

@zuiwomeirenxi just pinging you again for any suggestions.

Thanks,
Marc

zuiwomeirenxi commented 4 months ago

@zuiwomeirenxi just pinging you again for any suggestions.

Thanks, Marc

Hello Marc, although my modified code can run now, during the program execution, besides the reduction in loss, none of the metrics such as accuracy, AUC, precision, and F1 score have changed. They remain fixed at 60, 0.5, 5.7, and 0.099 respectively.

zuiwomeirenxi commented 4 months ago

@zuiwomeirenxi just pinging you again for any suggestions. Thanks, Marc

Hello Marc, although my modified code can run now, during the program execution, besides the reduction in loss, none of the metrics such as accuracy, AUC, precision, and F1 score have changed. They remain fixed at 60, 0.5, 5.7, and 0.099 respectively.

My programming skills are poor. If you have any questions, feel free to ask me, and I'll do my best to answer. If you could improve the code, I'd appreciate it if you could share it with me. Thank you!

kb1ooo commented 4 months ago

@zuiwomeirenxi can you tell me the steps that you used actually run it?

zuiwomeirenxi commented 4 months ago

@zuiwomeirenxi can you tell me the steps that you used actually run it?

First, you need to extract features. The code provided by the authors can extract features, but running the model proposed by the authors is not feasible. The model provided by the authors itself is flawed. I've modified a lot of code, and while the code is now running, the results are completely wrong. So, it would be best if you could make the modifications yourself and publish them.

kb1ooo commented 4 months ago

@zuiwomeirenxi ok thanks. It is unfortunately not worth my time to spend anymore time trying to figure out this code base. Especially since you could not replicate the paper's performance after your own efforts.