使用YOLOv3/Tensorflow检测时出现KeyError



每当我在自定义数据集上训练的模型在图像中检测到类时,我都会得到以下错误输出:

2020-10-14 19:47:45.924359: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory
2020-10-14 19:47:45.924386: 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.
2020-10-14 19:47:46.448878: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcuda.so.1
2020-10-14 19:47:46.451264: E tensorflow/stream_executor/cuda/cuda_driver.cc:314] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
2020-10-14 19:47:46.451281: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (jo-VirtualBox): /proc/driver/nvidia/version does not exist
2020-10-14 19:47:46.456495: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations:  AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2020-10-14 19:47:46.460729: I tensorflow/core/platform/profile_utils/cpu_utils.cc:104] CPU Frequency: 3500000000 Hz
2020-10-14 19:47:46.461061: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x41b2bc0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-10-14 19:47:46.461087: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
model_data/trade_names.txt
Traceback (most recent call last):
File "detection_custom.py", line 24, in <module>
detect_image(yolo, image_path, "./IMAGES/anf.jpg", input_size=YOLO_INPUT_SIZE, show=True, CLASSES=TRAIN_CLASSES, rectangle_colors=(255,0,0))
File "/home/jo/TensorFlow-2.x-YOLOv3/yolov3/utils.py", line 296, in detect_image
image = draw_bbox(original_image, bboxes, CLASSES=CLASSES, rectangle_colors=rectangle_colors)
File "/home/jo/TensorFlow-2.x-YOLOv3/yolov3/utils.py", line 157, in draw_bbox
label = "{}".format(NUM_CLASS[class_ind]) + score_str
KeyError: 14

也许有人知道我该怎么解决这个问题?

为了参考,我使用了本教程:https://www.youtube.com/watch?v=1A8B5Yy4tps文本形式:https://pylessons.com/YOLOv3-TF2-custrom-images/

我认为您在[pyleession]代码中遗漏了一些内容

首先你需要导入。。

from yolov3.yolov3 import Create_Yolov3

然后,

image_path   = "./IMAGES/[Your_images].jpg"

yolo = Create_Yolov3(input_size=YOLO_INPUT_SIZE , CLASSES = TRAIN_CLASSES)
yolo.load_weights("./checkpoints/yolov3_custom")
detect_image(yolo, image_path, "./IMAGES/[Your_saved_images].jpg", input_size=YOLO_INPUT_SIZE, show=True, CLASSES=TRAIN_CLASSES, rectangle_colors=(255,0,0))

在Pysession视频中显示,它对我有效

编辑1个

import os
os.environ['CUDA_VISIBLE_DEVICES'] = '-1'

相关内容

  • 没有找到相关文章

最新更新