0

我训练了一个 Yolov3 权重文件并将其转换为 .h5,在运行我的检测器时出现错误。

这是检测器的代码

from imageai.Detection import ObjectDetection

detector = ObjectDetection()
model_path = "./models/model.h5"
input_path = "./input/test1.jpg"
output_path = "./output/newimage.jpg"
detector.setModelTypeAsYOLOv3()
detector.setModelPath(model_path)
detector.loadModel()

detection = detector.detectObjectsFromImage(input_image=input_path, output_image_path=output_path)

for eachItem in detection:
    print(eachItem["name"] , " : ", eachItem["percentage_probability"])

完整的错误信息:

Traceback (most recent call last):
  File "C:\Users\Aidan\AppData\Local\Programs\Python\Python37\lib\site-packages\imageai\Detection\__init__.py", line 306, in detectObjectsFromImage
    self.numbers_to_names)
  File "C:\Users\Aidan\AppData\Local\Programs\Python\Python37\lib\site-packages\imageai\Detection\YOLO\utils.py", line 308, in retrieve_yolo_detections
    correct_yolo_boxes(boxes, image_size[1], image_size[0], image_input_size[0], image_input_size[1])
  File "C:\Users\Aidan\AppData\Local\Programs\Python\Python37\lib\site-packages\imageai\Detection\YOLO\utils.py", line 145, in correct_yolo_boxes
    boxes[i].xmin = int((boxes[i].xmin - x_offset) / x_scale * image_w)
ValueError: cannot convert float NaN to integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "detector.py", line 12, in <module>
    detection = detector.detectObjectsFromImage(input_image=input_path, output_image_path=output_path)
  File "C:\Users\Aidan\AppData\Local\Programs\Python\Python37\lib\site-packages\imageai\Detection\__init__.py", line 392, in detectObjectsFromImage
    "Ensure you specified correct input image, input type, output type and/or output image path ")
ValueError: Ensure you specified correct input image, input type, output type and/or output image path

我该如何解决这个错误?

4

0 回答 0