0

使用时出现错误imageAI
我已经尝试过故障排除file path并确定它是正确的,我哪里出错了?

我的操作系统 Ubuntu 18+ 并运行 Python 2+ 。我的代码如下:

Python

import os
from imageai.Detection import ObjectDetection

execution_path = os.getcwd()

custom_path = "/home/tcslab/Desktop/project-test/"

detector = ObjectDetection()
detector.setModelTypeAsYOLOv3()
detector.setModelPath( os.path.join(execution_path , "yolo.h5"))
detector.loadModel()

# if os.path.isfile(os.path.join(custom_path, "image.jpg")):
#     print(1)

detections = \
    detector.detectObjectsFromImage(extract_detected_objects = True,
                                    input_image=os.path.join(custom_path, "image.jpg"), 
                                    input_type="file", 
                                    output_type="file", 
                                    output_image_path=os.path.join(custom_path, "image.jpg"), 
                                    minimum_percentage_probability=30
                                    )

for eachObject in detections:
    print(eachObject["name"] , " : ", eachObject["percentage_probability"], " : ", eachObject["box_points"] )
    print("--------------------------------")

我得到的错误:

Traceback (most recent call last):   
File "test.py", line 16, in module
detections = detector.detectObjectsFromImage(extract_detected_objects = True, input_image=os.path.join(custom_path, "image.jpg"), input_type="file", output_type="file", output_image_path=os.path.join(custom_path), minimum_percentage_probability=30)
File "/home/tcslab/.local/lib/python2.7/site-packages/imageai/Detection/__init__.py", line 544, 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