Tensorflow 对象检测 API 字典错误

Tensorflow Object Detection API dictionary error

我正在使用 object_detection_tutorial.ipynb 来 运行 一个推论。

在我 运行 推断之后,我在 output_dict:

上得到了这个错误
  # Run inference
  output_dict = model(input_tensor)

  # All outputs are batches tensors.
  # Convert to numpy arrays, and take index [0] to remove the batch dimension.
  # We're only interested in the first num_detections.
  num_detections = int(output_dict.pop('num_detections'))
  output_dict = {key:value[0, :num_detections].numpy() 
                 for key,value in output_dict.items()}
  output_dict['num_detections'] = num_detections

错误日志:

Traceback (most recent call last): File "detect.py", line 140, in show_inference(detection_model, image_path) File "detect.py", line 109, in show_inference output_dict = run_inference_for_single_image(model, image_np) File "detect.py", line 94, in run_inference_for_single_image num_detections = int(output_dict.pop('num_detections')) TypeError: int() argument must be a string, a bytes-like object or a number, not 'Tensor'

已解决升级到 tensorflow 2.0