zwx8981 / TCSVT-2022-BVQA

Blindly Assess Quality of In-the-Wild Videos via Quality-aware Pre-training and Motion Perception
Apache License 2.0
46 stars 6 forks source link

RuntimeError: shape '[1, 256, 1, 1]' is invalid for input of size 8192 #18

Closed buaacarzp closed 2 years ago

buaacarzp commented 2 years ago

你好, 报错了,我用的提取特征的模型分别是DataParallel-00008.ptSLOWFAST_8x8_R50.pkl,是不是Motion默认模型不对啊?

$ python test_demo.py --trained_datasets C --model_path models/model_C --video_path=data/test.mp4
Video length: 240
use SpatialExtractor
use MotionExtractor
Traceback (most recent call last):
  File "test_demo.py", line 60, in <module>
    motion_features = get_motion_features(video_data, frame_batch_size=args.frame_batch_size, model='MotionExtractor', device=device)
  File "/data/zhoup/workspace/TCSVT-2022-BVQA/CNNfeatures_Motion.py", line 120, in get_features
    features_mean, features_std = extractor(inputs)
  File "/data/gaory/opt/anaconda3/envs/env_1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in __call__
    result = self.forward(*input, **kwargs)
  File "/data/zhoup/workspace/TCSVT-2022-BVQA/CNNfeatures_Motion.py", line 68, in forward
    features_mean = nn.functional.adaptive_avg_pool2d(x[1], 1)
  File "/data/gaory/opt/anaconda3/envs/env_1/lib/python3.6/site-packages/torch/nn/functional.py", line 768, in adaptive_avg_pool2d
    return torch._C._nn.adaptive_avg_pool2d(input, _output_size)
RuntimeError: shape '[1, 256, 1, 1]' is invalid for input of size 8192
2279209430 commented 2 years ago

@buaacarzp

你好,我们又测试了一下,可以跑通,没遇到上面的问题。 下面是追溯到你报错的关键行,可以对照一下输入、输出的尺寸是否匹配: 68行 120行 整体调试

感觉 8192是输入尺寸中 256与 32的乘积 (CNNfeatures_Motion.py 第 68行),可以检查下是否做了维度转换操作。 此外,还可以检查下 pytorch的版本是否匹配。

2279209430 commented 2 years ago

@buaacarzp

特征模型 DataParallel-00008.pt 和 SLOWFAST_8x8_R50.pkl 用的是正确的。可以确认下是否正确导入了模型。