tianyu0207 / RTFM

Official code for 'Weakly-supervised Video Anomaly Detection with Robust Temporal Feature Magnitude Learning' [ICCV 2021]
323 stars 77 forks source link

Error while creating a ground truth file #11

Closed Shashank56 closed 3 years ago

Shashank56 commented 3 years ago

I am using this file list/make_gt.py to generate the ground-truth file for my UCF Crime dataset. Instead of calculating the no. of frames using the features file as you did, I'm using cv2 to open the video and compute the no. of frames. But after some iterations at a video called Arson/Arson011_x264.mp4 the code is stopping here. https://github.com/tianyu0207/RTFM/blob/950243a2f7521d88033f6c164d4ba6307ecfab62/list/make_gt.py#L123 Only the videos that are going into this if (2 annotations) are stopping, others are fine https://github.com/tianyu0207/RTFM/blob/950243a2f7521d88033f6c164d4ba6307ecfab62/list/make_gt.py#L50 How to resolve this?

tianyu0207 commented 3 years ago

I am using this file list/make_gt.py to generate the ground-truth file for my UCF Crime dataset. Instead of calculating the no. of frames using the features file as you did, I'm using cv2 to open the video and compute the no. of frames. But after some iterations at a video called Arson/Arson011_x264.mp4 the code is stopping here. https://github.com/tianyu0207/RTFM/blob/950243a2f7521d88033f6c164d4ba6307ecfab62/list/make_gt.py#L123

Only the videos that are going into this if (2 annotations) are stopping, others are fine https://github.com/tianyu0207/RTFM/blob/950243a2f7521d88033f6c164d4ba6307ecfab62/list/make_gt.py#L50

How to resolve this?

Hi, I did not encounter this problem. I have uploaded the gt-ucf.npy to list. You can use it as the ground truth with the ucf-i3d-test.list.

Shashank56 commented 3 years ago

After using the gt file you have provided, I am getting this error.

Traceback (most recent call last):
  File "main.py", line 44, in <module>
    auc = test(test_loader, model, args, viz, device)
  File "/home/yggdrasil/WorkingDirectory/FinalYearProject/RTFM-I3D/RTFM/test_10crop.py", line 30, in test
    fpr, tpr, threshold = roc_curve(list(gt), pred)
  File "/home/yggdrasil/anaconda3/lib/python3.7/site-packages/sklearn/utils/validation.py", line 63, in inner_f
    return f(*args, **kwargs)
  File "/home/yggdrasil/anaconda3/lib/python3.7/site-packages/sklearn/metrics/_ranking.py", line 914, in roc_curve
    y_true, y_score, pos_label=pos_label, sample_weight=sample_weight)
  File "/home/yggdrasil/anaconda3/lib/python3.7/site-packages/sklearn/metrics/_ranking.py", line 693, in _binary_clf_curve
    check_consistent_length(y_true, y_score, sample_weight)
  File "/home/yggdrasil/anaconda3/lib/python3.7/site-packages/sklearn/utils/validation.py", line 263, in check_consistent_length
    " samples: %r" % [int(l) for l in lengths])
ValueError: Found input variables with inconsistent numbers of samples: [1114144, 1109824]

The size of prediction and the size of gt file are not same.

tianyu0207 commented 3 years ago

After using the gt file you have provided, I am getting this error.

Traceback (most recent call last):
  File "main.py", line 44, in <module>
    auc = test(test_loader, model, args, viz, device)
  File "/home/yggdrasil/WorkingDirectory/FinalYearProject/RTFM-I3D/RTFM/test_10crop.py", line 30, in test
    fpr, tpr, threshold = roc_curve(list(gt), pred)
  File "/home/yggdrasil/anaconda3/lib/python3.7/site-packages/sklearn/utils/validation.py", line 63, in inner_f
    return f(*args, **kwargs)
  File "/home/yggdrasil/anaconda3/lib/python3.7/site-packages/sklearn/metrics/_ranking.py", line 914, in roc_curve
    y_true, y_score, pos_label=pos_label, sample_weight=sample_weight)
  File "/home/yggdrasil/anaconda3/lib/python3.7/site-packages/sklearn/metrics/_ranking.py", line 693, in _binary_clf_curve
    check_consistent_length(y_true, y_score, sample_weight)
  File "/home/yggdrasil/anaconda3/lib/python3.7/site-packages/sklearn/utils/validation.py", line 263, in check_consistent_length
    " samples: %r" % [int(l) for l in lengths])
ValueError: Found input variables with inconsistent numbers of samples: [1114144, 1109824]

The size of prediction and the size of gt file are not same.

Could you double-check with the feature extracted? Please follow the frames setup from our paper.