我正在运行代码以从本文中学习如何教AI / ML用于对象检测: https://medium.com/deepquestai/train-object-detection-ai-with-6-lines-of-code-6d087063f6ff (非常棒的BTW;-)
我下载了预训练的模型并在Google Colab上运行
似乎我收到了以下错误:
'''
--> 761 image_frame = image.copy()
762 image_frame2 = image.copy()
763 height, width, channels = image.shape
'AttributeError: 'NoneType' object has no attribute 'copy'
on line 8: ----> 8 detections =
detector.detectObjectsFromImage(input_image="holo3.jpg",
output_image_path="holo3-detected.jpg")'
请问有什么可以帮助的,因为它应该是经过预先训练,经过测试的代码?
我搜索了Stackoverflow,但没有找到答案。
from imageai.Detection.Custom import CustomObjectDetection
detector = CustomObjectDetection()
detector.setModelTypeAsYOLOv3()
detector.setModelPath("hololens-ex-60--loss-2.76.h5")
detector.setJsonPath("detection_config.json")
detector.loadModel()
detections = detector.detectObjectsFromImage(input_image="holo3.jpg",
output_image_path="holo3-detected.jpg")
for detection in detections:
print(detection["name"], " : ", detection["percentage_probability"], " : ", detection["box_points"])
AttributeError Traceback (most recent call last)
<ipython-input-6-31fc5f7df048> in <module>()
6 detector.setJsonPath("detection_config.json")
7 detector.loadModel()
----> 8 detections =
detector.detectObjectsFromImage(input_image="holo3.jpg",
output_image_path="holo3-detected.jpg")
9 for detection in detections:
10 print(detection["name"], " : ",
detection["percentage_probability"], " : ", detection["box_points"])
/usr/local/lib/python3.6/dist-packages/imageai/Detection/Custom/__init__.py in detectObjectsFromImage(self, input_image, output_image_path, input_type, output_type, extract_detected_objects, minimum_percentage_probability, nms_treshold, display_percentage_probability, display_object_name)
759
760
--> 761 image_frame = image.copy()
762 image_frame2 = image.copy()
763 height, width, channels = image.shape
AttributeError: 'NoneType' object has no attribute 'copy'
答案 0 :(得分:0)
由于图像文件夹中不存在火车和验证文件夹注释XML图像路径,我发现了类似的错误。检查图像名称与注释XML文件路径相同。