Home > Software design >  SyntaxError: invalid syntax. Raise ValueError(f'Unknown heatmap type - {self._box_heatmap_type}
SyntaxError: invalid syntax. Raise ValueError(f'Unknown heatmap type - {self._box_heatmap_type}

Time:09-17

I'm following this TensorFlow guide for object detection models and I've gotten to part 6, which is training your program. I've input this line of code,

python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config

But it keeps resulting in the syntax error here.

(tensorflow1) C:\tensorflow1\models\research\object_detection>python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
2022-09-16 14:38:10.767310: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2022-09-16 14:38:10.767443: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
  File "train.py", line 53, in <module>
    from object_detection.builders import model_builder
  File "C:\tensorflow1\models\research\object_detection\builders\model_builder.py", line 34, in <module>
    from object_detection.core import target_assigner
  File "C:\tensorflow1\models\research\object_detection\core\target_assigner.py", line 1051
    raise ValueError(f'Unknown heatmap type - {self._box_heatmap_type}')
                                                                      ^
SyntaxError: invalid syntax

It's happened before but I managed to fix it by going back to the file and editting the changes it asks for. But this time, if I take away that quote it's on, the whole line has a red squiggly. I've never used Python or Anaconda before, and this is my first time touching it. Any help would be appreciated. I've read online this is due to my Python being an older version, and that line of code doesn't work with the old version. I think I'm using 3.5, but I'm not sure if updating the version will break everything, because I think TensorFlow only works with 3.5

CodePudding user response:

f-strings were not introduced until after python 3.5, you'll need to use an older syntax. Use:

raise ValueError('Unknown heatmap type - {}'.format(self._box_heatmap_type))

or something similar.

CodePudding user response:

Clearly it is that the training stage is not being allowed to be processed through GPU which returns a warning

2022-09-16 14:38:10.767310: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found

I would recommend you read the section of the link you shared that indicates how to upgrade cudCNN for DLL errors:

conda create -n tensorflow2 pip python=3.5
conda install tensorflow-gpu

if this doesn't work you can try using a different pipeline configuration, for that you need to replace the pipeline config parameter --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config

with this TPU compatible pipeline configuration file --pipeline_config_path=training/ssd_resnet50_v1_fpn_shared_box_predictor_640x640_coco14_sync.config

you can also try to add a new parameter, --use_tpu=true (if available).

also see:

  • Related