Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

SyntaxError: invalid syntax #1115

Closed
liuxufenfeiya opened this issue Aug 25, 2021 · 4 comments
Closed

SyntaxError: invalid syntax #1115

liuxufenfeiya opened this issue Aug 25, 2021 · 4 comments

Comments

@liuxufenfeiya
Copy link

the same error as#875,but use the resulotion of #820 was not work(change the cfg.pretty_text to cfg.text,or change the cfg.text to cfg.pretty_text,return the same error)
my train command was
./tools/dist_train.sh configs/recognition/slowfast/slowfast_r50_video_4x16x1_256e_kinetics400_rgb.py 1 --resume-from ckpt/slowfast_r50_video_4x16x1_256e_kinetics400_rgb_20200826-f85b90c5.pth

the error code was:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/mmcv/utils/config.py", line 100, in _validate_py_syntax
    ast.parse(content)
  File "/opt/conda/lib/python3.8/ast.py", line 49, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 1
    /mnt/lustre/xusu/refactor/retest_video_ckpts/mmaction2/configs/recognition/slowfast/slowfast_r50_video_4x16x1_256e_kinetics400_rgb.py
    ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./tools/train.py", line 201, in <module>
    main()
  File "./tools/train.py", line 189, in main
    train_model(
  File "/mnt/cv_model/mmaction2/mmaction/apis/train.py", line 159, in train_model
    runner.resume(cfg.resume_from)
  File "/opt/conda/lib/python3.8/site-packages/mmcv/runner/base_runner.py", line 374, in resume
    config = mmcv.Config.fromstring(
  File "/opt/conda/lib/python3.8/site-packages/mmcv/utils/config.py", line 344, in fromstring
    cfg = Config.fromfile(temp_file.name)
  File "/opt/conda/lib/python3.8/site-packages/mmcv/utils/config.py", line 315, in fromfile
    cfg_dict, cfg_text = Config._file2dict(filename,
  File "/opt/conda/lib/python3.8/site-packages/mmcv/utils/config.py", line 204, in _file2dict
    Config._validate_py_syntax(filename)
  File "/opt/conda/lib/python3.8/site-packages/mmcv/utils/config.py", line 102, in _validate_py_syntax
    raise SyntaxError('There are syntax errors in config '
SyntaxError: There are syntax errors in config file /tmp/tmp8ul80gem.py: invalid syntax (<unknown>, line 1)
Exception ignored in: <function _TemporaryFileCloser.__del__ at 0x7f5b840f6d30>
Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/tempfile.py", line 441, in __del__
    self.close()
  File "/opt/conda/lib/python3.8/tempfile.py", line 437, in close
    unlink(self.name)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpleg_mvy9/tmp8z6fmvc_.py'
@kennymckormick
Copy link
Member

Maybe you should use --load_from instead of --resume_from. Resuming from a released checkpoint doesn't make sense.

@liuxufenfeiya
Copy link
Author

Maybe you should use --load_from instead of --resume_from. Resuming from a released checkpoint doesn't make sense.

sorry,it didn't work.

./tools/dist_train.sh configs/recognition/slowfast/slowfast_r50_video_4x16x1_256e_kinetics400_rgb.py 1 --load-from ckpt/slowfast_r50_video_4x16x1_256e_kinetics400_rgb_20200826-f85b90c5.pth

error was:
train.py: error: unrecognized arguments: --load-from ckpt/slowfast_r50_video_4x16x1_256e_kinetics400_rgb_20200826-f85b90c5.pth

@kennymckormick
Copy link
Member

You should set the argument load_from in the config file.

@liuxufenfeiya
Copy link
Author

thanks,it works

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants