bradyz / 2020_CARLA_challenge

"Learning by Cheating" (CoRL 2019) submission for the 2020 CARLA Challenge
181 stars 49 forks source link

AttributeError: 'PosixPath' object has no attribute 'decode' when training stage2 #19

Closed AIasd closed 4 years ago

AIasd commented 4 years ago

Hi, I finished training stage 1 successfully and tried to train stage 2 model.

I notice that the command in README is python3 -m carla_project/src/image_model --dataset_dir /path/to/data.

One minor typo: I think it should be python3 -m carla_project/src/image_model --dataset_dir /path/to/data --teacher_path /path/to/teacher/checkpoint since teacher_path is required field.

After running this command with the path to the checkpoint of my stage1 model, however, I encountered the following error:

Traceback (most recent call last):
  File "carla_project/src/image_model.py", line 364, in <module>
    main(parsed)
  File "carla_project/src/image_model.py", line 322, in main
    model = ImageModel(hparams, teacher_path=hparams.teacher_path)
  File "carla_project/src/image_model.py", line 100, in __init__
    self.teacher = MapModel.load_from_checkpoint(teacher_path)
  File "/home/zhongzzy9/anaconda3/envs/carla99/lib/python3.7/site-packages/pytorch_lightning/core/saving.py", line 142, in load_from_checkpoint
    checkpoint = pl_load(checkpoint_path, map_location=lambda storage, loc: storage)
  File "/home/zhongzzy9/anaconda3/envs/carla99/lib/python3.7/site-packages/pytorch_lightning/utilities/cloud_io.py", line 8, in load
    if urlparse(path_or_url).scheme == '' or Path(path_or_url).drive:  # no scheme or with a drive letter
  File "/home/zhongzzy9/anaconda3/envs/carla99/lib/python3.7/urllib/parse.py", line 367, in urlparse
    url, scheme, _coerce_result = _coerce_args(url, scheme)
  File "/home/zhongzzy9/anaconda3/envs/carla99/lib/python3.7/urllib/parse.py", line 123, in _coerce_args
    return _decode_args(args) + (_encode_result,)
  File "/home/zhongzzy9/anaconda3/envs/carla99/lib/python3.7/urllib/parse.py", line 107, in _decode_args
    return tuple(x.decode(encoding, errors) if x else '' for x in args)
  File "/home/zhongzzy9/anaconda3/envs/carla99/lib/python3.7/urllib/parse.py", line 107, in <genexpr>
    return tuple(x.decode(encoding, errors) if x else '' for x in args)
AttributeError: 'PosixPath' object has no attribute 'decode'

Did you encounter this error by any chance before?

bradyz commented 4 years ago

can you try

self.teacher = MapModel.load_from_checkpoint(str(teacher_path))

AIasd commented 4 years ago

Hi @bradyz Thanks for the help! This indeed solves the error. After fixing it, I encountered

  File "/home/zhongzzy9/Documents/self-driving-car/2020_CARLA_challenge/carla_project/src/map_model.py", line 85, in __init__
    self.to_heatmap = ToHeatmap(hparams.heatmap_radius)
AttributeError: 'dict' object has no attribute 'heatmap_radius'

I fixed that by manually converting hparams from dictionary to argparse.namespace in the map_model.py and now the training runs successfully!