PaddleVideo icon indicating copy to clipboard operation
PaddleVideo copied to clipboard

快速入门文档遇到问题

Open ZhangHandi opened this issue 3 years ago • 1 comments

  1. install.md

ppvideo --model_name='ppTSM' --video_file='data/example.mp4'

ppvideo包使用命令中data/example.mp4 文件不存在,替换为data/example.avi 可使用

  1. paddlevideo包使用教程 快速开始,同样存在example.mp4不存在问题,更换为example.avi,执行 result=clas.predict(video_file),会报错:
  File "<stdin>", line 1, in <module>
  File "/usr/local/python3.7.0/lib/python3.7/site-packages/ppvideo/tools/paddlevideo_clas.py", line 294, in predict
    v = utils.decode(video, self.args)
AttributeError: module 'tools.utils' has no attribute 'decode'
  1. 开始使用 模型训练运行如下代码后报错:
python3 -m paddle.distributed.launch \
    --gpus="0,1,2,3" \
    main.py \
        --validate \
        -c ./configs/example.yaml
Traceback (most recent call last):
  File "main.py", line 87, in <module>
    main()
  File "main.py", line 64, in main
    cfg = get_config(args.config, overrides=args.override)
  File "/workspace/PaddleVideo/paddlevideo/utils/config.py", line 169, in get_config
    config = parse_config(fname)
  File "/workspace/PaddleVideo/paddlevideo/utils/config.py", line 53, in parse_config
    yaml_config = AttrDict(yaml.load(fopen, Loader=yaml.SafeLoader))
  File "/usr/local/python3.7.0/lib/python3.7/site-packages/yaml/__init__.py", line 114, in load
    return loader.get_single_data()
  File "/usr/local/python3.7.0/lib/python3.7/site-packages/yaml/constructor.py", line 49, in get_single_data
    node = self.get_single_node()
  File "/usr/local/python3.7.0/lib/python3.7/site-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
  File "/usr/local/python3.7.0/lib/python3.7/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/usr/local/python3.7.0/lib/python3.7/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/usr/local/python3.7.0/lib/python3.7/site-packages/yaml/composer.py", line 127, in compose_mapping_node
    while not self.check_event(MappingEndEvent):
  File "/usr/local/python3.7.0/lib/python3.7/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/usr/local/python3.7.0/lib/python3.7/site-packages/yaml/parser.py", line 439, in parse_block_mapping_key
    "expected <block end>, but found %r" % token.id, token.start_mark)
yaml.parser.ParserError: while parsing a block mapping
  in "./configs/example.yaml", line 2, column 1
expected <block end>, but found '<block mapping start>'
  in "./configs/example.yaml", line 4, column 5
INFO 2021-09-24 10:25:06,225 launch_utils.py:327] terminate all the procs
ERROR 2021-09-24 10:25:06,226 launch_utils.py:584] ABORT!!! Out of all 4 trainers, the trainer process with rank=[0, 1, 2, 3] was aborted. Please check its log.
INFO 2021-09-24 10:25:09,229 launch_utils.py:327] terminate all the procs

ZhangHandi avatar Sep 24 '21 10:09 ZhangHandi

根据提供的错误信息,问题出现在解析 YAML 配置文件时。具体的错误指出是在解析块映射(block mapping)的过程中遇到了问题。错误信息指向了配置文件 ./configs/example.yaml 的第 4 行,这表明 YAML 文件的格式可能有误,导致解析失败。

解决这个问题的步骤如下:

  1. 检查 YAML 文件的格式:确保 YAML 文件的格式是正确的。YAML 文件对缩进非常敏感,必须使用空格而不是制表符进行缩进,并且要保证键值对的缩进级别正确。比如:

    # 正确的格式
    key:
      subkey: value
    

    而不是:

    # 错误的格式
    key:
    subkey: value
    
  2. 检查特定行的格式:错误信息指出问题出现在 example.yaml 的第 4 行,查看该行及其周围的行,确认是否有缩进或格式错误。

  3. 验证 YAML 文件:你可以使用在线的 YAML 验证工具,或者在 Python 中使用 yaml 库尝试加载配置文件,以检查是否有语法错误。

    import yaml
    
    with open('./configs/example.yaml', 'r') as file:
        try:
            yaml.safe_load(file)
            print("YAML format is OK")
        except yaml.YAMLError as exc:
            print("YAML format error:", exc)
    
  4. 修正 YAML 文件:根据上述检查的结果,修正 YAML 文件中的错误。

  5. 重新运行:在修正了 YAML 文件之后,重新运行你的代码。

请注意,此错误并不是由于 Python 代码本身的逻辑错误引起的,而是由于配置文件的格式问题。确保所有的配置项都正确缩进,并且遵守 YAML 语法规则。

luyao-cv avatar Mar 14 '24 04:03 luyao-cv