tensorflow - plt.show() 不显示图像
问题描述
我找不到为什么这个 plt.show() 不起作用。我正在使用 Tensorflow 中给出的代码: https ://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/auto_examples/plot_object_detection_saved_model.html
我发现解决方案说我应该使用 plt.show(block=false) 并添加 plt.pause(5) 但它没有用。请帮忙。
运行代码后,我得到: Running inference for image... Done,但它没有显示任何图像。
# 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(detections.pop('num_detections'))
detections = {key: value[0, :num_detections].numpy()
for key, value in detections.items()}
detections['num_detections'] = num_detections
# detection_classes should be ints.
detections['detection_classes'] = detections['detection_classes'].astype(np.int64)
image_np_with_detections = image_np.copy()
viz_utils.visualize_boxes_and_labels_on_image_array(
image_np_with_detections,
detections['detection_boxes'],
detections['detection_classes'],
detections['detection_scores'],
category_index,
use_normalized_coordinates=True,
max_boxes_to_draw=200,
min_score_thresh=.30,
agnostic_mode=False)
plt.figure()
plt.imshow(image_np_with_detections)
print('Done')
plt.show()
解决方案
推荐阅读
- python-3.x - 具有不同权重的两个数据集的线性回归。如何最小化错误?
- python-3.x - 当我点击提交表单时,我收到了这个错误
- javascript - Javascript跳过循环
- reactjs - 如何在 React Actions Redux 中获取状态数据?
- javascript - 为什么 AJAX 中的 document.write() 会在加载之前覆盖整个页面?
- python - 将reduce函数应用于列表
- java - 在使用 com.google.api.client.http.HttpRequest 的 POST 请求上需要帮助
- docker - 如何在 docker-compose 文件中使用 wait-for-it?
- ios - 为什么我的函数在使用 DispatchQueue 时不执行?
- properties - Node-Red:从节点更新属性