ekosman / AnomalyDetectionCVPR2018-Pytorch

Pytorch version of - https://github.com/WaqasSultani/AnomalyDetectionCVPR2018
172 stars 52 forks source link

TypeError: 'dict' object is not callable. #171

Closed asif-nuaa closed 1 year ago

asif-nuaa commented 1 year ago

I am getting TypeError, when I try to execute the command.

c:> python video_demo.py --feature_extractor "features/c3d.pickle" --ad_model "pretrained/MFNet3D_UCF-101_Split-1_96.3.pth" --n_segments 32

would you please give more desciption about the parameters (feature_extractor, --ad_model, path-to-pretrained-fe) and their possible values.

ekosman commented 1 year ago

Thanks for reporting!

Could you please paste here the complete stack trace?

asif-nuaa commented 1 year ago

Please check the stacktrace.

C:\Users\user\HAR\AnomalyDetectionCVPR2018-Pytorch-main>python video_demo.py --feature_extractor "C:\Users\user\HAR\AnomalyDetectionCVPR2018-Pytorch-main\C3D\c3d.pickle" --ad_model "C:\Users\user\HAR\AnomalyDetectionCVPR2018-Pytorch-main\pretrained\MFNet3D_UCF-101_Split-1_96.3.pth" C:\Users\user\HAR\AnomalyDetectionCVPR2018-Pytorch-main\video_demo.py:137: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requiresgrad(True), rather than torch.tensor(sourceTensor). features = torch.tensor(features).to(device) # pylint: disable=not-callable Traceback (most recent call last): File "C:\Users\user\HAR\AnomalyDetectionCVPR2018-Pytorch-main\video_demo.py", line 278, in open_file self._y_pred = ad_prediction( File "C:\Users\user\HAR\AnomalyDetectionCVPR2018-Pytorch-main\video_demo.py", line 139, in ad_prediction preds = model(features) File "C:\Users\user\HAR\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, *kwargs) File "C:\Users\user\HAR\AnomalyDetectionCVPR2018-Pytorch-main\network\TorchUtils.py", line 271, in forward return self.model(args, **kwargs) TypeError: 'dict' object is not callable

ekosman commented 1 year ago

You need to pass a valid AD model to to option --ad_model. You can find such models under exps/.

See the following command for example: python video_demo.py --feature_extractor pretrained/c3d.pickle --ad_model exps/c3d/models/epoch_80000.pt --n_segments 32