PaddlePaddle / models

Officially maintained, supported by PaddlePaddle, including CV, NLP, Speech, Rec, TS, big models and so on.
Apache License 2.0
6.9k stars 2.91k forks source link

https://gitee.com/paddlepaddle/models/tree/develop/PaddleCV/video/application/video_tag运行test失败啊啊啊啊 #5306

Open livingbody opened 3 years ago

livingbody commented 3 years ago

https://gitee.com/paddlepaddle/models/tree/develop/PaddleCV/video/application/video_tag运行test失败啊啊啊啊 %cd ~/video_tag/ !python videotag_test.py /home/aistudio/video_tag /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/utils.py:26: DeprecationWarning:np.intis a deprecated alias for the builtinint. To silence this warning, useintby itself. Doing this will not modify any behavior and is safe. When replacingnp.int, you may wish to use e.g.np.int64ornp.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information. Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations def convert_to_list(value, n, name, dtype=np.int): Namespace(extractor_config='configs/tsn.yaml', extractor_name='TSN', extractor_weights='weights/tsn', filelist='./data/VideoTag_test.list.txt', label_file='label_3396.txt', predictor_config='configs/attention_lstm.yaml', predictor_name='AttentionLSTM', predictor_weights='weights/attention_lstm', save_dir='data/VideoTag_results', use_gpu=True) [INFO: videotag_test.py: 239]: Namespace(extractor_config='configs/tsn.yaml', extractor_name='TSN', extractor_weights='weights/tsn', filelist='./data/VideoTag_test.list.txt', label_file='label_3396.txt', predictor_config='configs/attention_lstm.yaml', predictor_name='AttentionLSTM', predictor_weights='weights/attention_lstm', save_dir='data/VideoTag_results', use_gpu=True) /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py:1150: UserWarning: There are no operators in the program to be executed. If you pass Program manually, please use fluid.program_guard to ensure the current Program is being used. warnings.warn(error_info) W0501 18:28:51.170547 4107 device_context.cc:362] Please NOTE: device: 0, GPU Compute Capability: 7.0, Driver API Version: 10.1, Runtime API Version: 10.1 W0501 18:28:51.176075 4107 device_context.cc:372] device: 0, cuDNN Version: 7.6. [INFO: videotag_test.py: 137]: load extractor weights from weights/tsn [INFO: tsn.py: 157]: Load pretrain weights from weights/tsn, exclude fc layer. ===pretrain=== weights/tsn Traceback (most recent call last): File "videotag_test.py", line 240, in main() File "videotag_test.py", line 154, in main feed=extractor_feeder.feed(feed_data)) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 1110, in run six.reraise(*sys.exc_info()) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/six.py", line 703, in reraise raise value File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 1108, in run return_merged=return_merged) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 1238, in _run_impl use_program_cache=use_program_cache) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py", line 1328, in _run_program [fetch_var_name]) RuntimeError: In user code:

File "videotag_test.py", line 240, in <module>
  main()
File "videotag_test.py", line 127, in main
  extractor_model.build_model()
File "/home/aistudio/video_tag/models/tsn/tsn.py", line 94, in build_model
  class_dim=cfg['class_dim'])
File "/home/aistudio/video_tag/models/tsn/tsn_res_model.py", line 125, in net
  name='conv1')
File "/home/aistudio/video_tag/models/tsn/tsn_res_model.py", line 50, in conv_bn_layer
  bias_attr=False)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/nn.py", line 1622, in conv2d
  "data_format": data_format,
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layer_helper.py", line 43, in append_op
  return self.main_program.current_block().append_op(*args, **kwargs)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/framework.py", line 3027, in append_op
  attrs=kwargs.get("attrs", None))
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/framework.py", line 2107, in __init__
  for frame in traceback.extract_stack():

PreconditionNotMetError: Tensor not initialized yet when Tensor::type() is called.
  [Hint: holder_ should not be null.] (at /paddle/paddle/fluid/framework/tensor.h:202)
  [operator < conv2d > error]`
liym27 commented 3 years ago

您好,抱歉,我们正在复现和定位刚问题,稍后将给您回复。感谢反馈问题。

huangjun12 commented 3 years ago

https://github.com/PaddlePaddle/PaddleVideo/tree/application/VideoTag#使用方法 可以参考PaddleVideo repo给出的使用文档教程

Interesting6 commented 3 years ago

https://github.com/PaddlePaddle/PaddleVideo/tree/application/VideoTag#使用方法 可以参考PaddleVideo repo给出的使用文档教程

教程是没错。。。但跟这个问题有毛关系。。。。没解决问题呀。。。

同样的环境,运行tsn_extractor.py没问题,而运行videotag_test.py就出现了与楼主一样的问题。 我看这俩代码也都差不多,后者重复使用了前者的步骤,可就不理解了为啥前者没问题,后者报一个张量未被初始化的问题。。。

Interesting6 commented 3 years ago

您好,抱歉,我们正在复现和定位刚问题,稍后将给您回复。感谢反馈问题。

您好,请问一下定位好问题有解决方案了吗?

ZhongkaiZ commented 3 years ago

您好,抱歉,我们正在复现和定位刚问题,稍后将给您回复。感谢反馈问题。

您好,请问一下定位好问题有解决方案了吗?

遇到了同样的问题,同样的bug,请问你的bug解决了吗?

CLIsVeryOK commented 2 years ago

遇到同样的问题,请问有解决嘛? RuntimeError: In user code:

File "/Users/admin/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-C/ch-0/212.5284.44/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 2173, in <module>
  main()
File "/Users/admin/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-C/ch-0/212.5284.44/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 2164, in main
  globals = debugger.run(setup['file'], None, None, is_module)
File "/Users/admin/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-C/ch-0/212.5284.44/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1476, in run
  return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
File "/Users/admin/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-C/ch-0/212.5284.44/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1483, in _exec
  pydev_imports.execfile(file, globals, locals)  # execute the script
File "/Users/admin/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-C/ch-0/212.5284.44/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
  exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/admin/Desktop/work/5.wksp/models/PaddleCV/video/application/video_tag/videotag_test.py", line 242, in <module>
  main()
File "/Users/admin/Desktop/work/5.wksp/models/PaddleCV/video/application/video_tag/videotag_test.py", line 129, in main
  extractor_model.build_model()
File "/Users/admin/Desktop/work/5.wksp/models/PaddleCV/video/application/video_tag/models/tsn/tsn.py", line 92, in build_model
  class_dim=cfg['class_dim'])
File "/Users/admin/Desktop/work/5.wksp/models/PaddleCV/video/application/video_tag/models/tsn/tsn_res_model.py", line 125, in net
  name='conv1')
File "/Users/admin/Desktop/work/5.wksp/models/PaddleCV/video/application/video_tag/models/tsn/tsn_res_model.py", line 50, in conv_bn_layer
  bias_attr=False)
File "/Users/admin/opt/anaconda3/envs/py3.7/lib/python3.7/site-packages/paddle/fluid/layers/nn.py", line 1651, in conv2d
  "data_format": data_format,
File "/Users/admin/opt/anaconda3/envs/py3.7/lib/python3.7/site-packages/paddle/fluid/layer_helper.py", line 43, in append_op
  return self.main_program.current_block().append_op(*args, **kwargs)
File "/Users/admin/opt/anaconda3/envs/py3.7/lib/python3.7/site-packages/paddle/fluid/framework.py", line 3184, in append_op
  attrs=kwargs.get("attrs", None))
File "/Users/admin/opt/anaconda3/envs/py3.7/lib/python3.7/site-packages/paddle/fluid/framework.py", line 2224, in __init__
  for frame in traceback.extract_stack():

PreconditionNotMetError: Tensor not initialized yet when Tensor::type() is called.
  [Hint: holder_ should not be null.] (at /home/Paddle/paddle/fluid/framework/tensor.h:218)
  [operator < conv2d > error]

python-BaseException

Process finished with exit code 1

CLIsVeryOK commented 2 years ago

需要在代码最开始加入 import paddle paddle.enable_static(), 注意是一定要在开头

from utils.utility import check_cuda
from utils.utility import check_version
import paddle
paddle.enable_static()

还有一种可能是加载模型路径不对 code里面是没有weight的,需要从paddlehub下载一下,放到同级目录的weights/xxx.pdmodel 然后修改arg.parse

parser.add_argument(
        '--extractor_weights',
        type=str,
        default='weights/tsn.pdmodel',
        help='extractor weight path')
    parser.add_argument(
        '--predictor_weights',
        '--pweights',
        type=str,
        default='weights/attention_lstm.pdmodel',
        help='predictor weight path')