Open wuliwan opened 3 years ago
Hi, @wuliwan
Which version of python do you use? By google searching ib2to3.pgen2.parse.ParseError: bad input: type=3, value="'model'", context=('\n', (4, 0))
, I found that this error may be caused by lower version of python (see this issue).
You could try with python 3.7 or 3.8.
I got the same error.
It is not because of Python version.
In my case, the error comes from the config file.
Reason In config file, everything should be a dictionary, ONLY dictionary, but I wrote some codes to define classes, codes to do this do that, then those lines of codes caused that error.
Solution: Keep only lines that define the model structure.
I got the same error.
It is not because of Python version.
In my case, the error comes from the config file.
Reason In config file, everything should be a dictionary, ONLY dictionary, but I wrote some codes to define classes, codes to do this do that, then those lines of codes caused that error.
Solution: Keep only lines that define the model structure.
Can you tell me how to modify the code? thank you very much
Hello, when I enter code with "python tools/train.py configs/swin/upernet_swin_tiny_patch4_window7_512x512_160k_ade20k.py --options model.pretrained=models/upernet_swin_tiny_patch4_window7_512x512.pth [model.backbone.use_checkpoint=True]" on my windows,it happened: (RTX3090) D:\Swin-Transformer-Semantic-Segmentation>python tools/train.py configs/swin/upernet_swin_tiny_patch4_window7_512x512_160k_ade20k.py --options model.pretrained=models/upernet_swin_tiny_patch4_window7_512x512.pth [model.backbone.use_checkpoint=True] .\work_dirs\upernet_swin_tiny_patch4_window7_512x512_160k_ade20k Traceback (most recent call last): File "D:\Anaconda\envs\RTX3090\lib\site-packages\yapf\yapflib\pytree_utils.py", line 115, in ParseCodeToTree tree = parser_driver.parse_string(code, debug=False) File "D:\Anaconda\envs\RTX3090\lib\lib2to3\pgen2\driver.py", line 104, in parse_string return self.parse_tokens(tokens, debug) File "D:\Anaconda\envs\RTX3090\lib\lib2to3\pgen2\driver.py", line 72, in parse_tokens if p.addtoken(type, value, (prefix, start)): File "D:\Anaconda\envs\RTX3090\lib\lib2to3\pgen2\parse.py", line 159, in addtoken raise ParseError("bad input", type, value, context) lib2to3.pgen2.parse.ParseError: bad input: type=3, value="'model'", context=('\n', (4, 0))
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "D:\Anaconda\envs\RTX3090\lib\site-packages\yapf\yapflib\pytree_utils.py", line 121, in ParseCodeToTree tree = parser_driver.parse_string(code, debug=False) File "D:\Anaconda\envs\RTX3090\lib\lib2to3\pgen2\driver.py", line 104, in parse_string return self.parse_tokens(tokens, debug) File "D:\Anaconda\envs\RTX3090\lib\lib2to3\pgen2\driver.py", line 72, in parse_tokens if p.addtoken(type, value, (prefix, start)): File "D:\Anaconda\envs\RTX3090\lib\lib2to3\pgen2\parse.py", line 159, in addtoken raise ParseError("bad input", type, value, context) lib2to3.pgen2.parse.ParseError: bad input: type=3, value="'model'", context=('\n', (4, 0))
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "tools/train.py", line 164, in
main()
File "tools/train.py", line 101, in main
cfg.dump(osp.join(cfg.work_dir, osp.basename(args.config)))
File "D:\Anaconda\envs\RTX3090\lib\site-packages\mmcv\utils\config.py", line 458, in dump
f.write(self.pretty_text)
File "D:\Anaconda\envs\RTX3090\lib\site-packages\mmcv\utils\config.py", line 413, in prettytext
text, = FormatCode(text, style_config=yapf_style, verify=True)
File "D:\Anaconda\envs\RTX3090\lib\site-packages\yapf\yapflib\yapf_api.py", line 147, in FormatCode
tree = pytree_utils.ParseCodeToTree(unformatted_source)
File "D:\Anaconda\envs\RTX3090\lib\site-packages\yapf\yapflib\pytree_utils.py", line 127, in ParseCodeToTree
raise e
File "D:\Anaconda\envs\RTX3090\lib\site-packages\yapf\yapflib\pytree_utils.py", line 125, in ParseCodeToTree
ast.parse(code)
File "D:\Anaconda\envs\RTX3090\lib\ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "", line 4
'model': dict(
^
SyntaxError: invalid syntax
so I want ask the run code example for windows when I train on one gpu?