我正在运行代码来学习如何从本文中教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'发布于 2019-12-01 17:24:41
我发现了这个类似的错误,原因是火车和验证文件夹注释XML图像路径在图像文件夹中不存在。检查图像名称是否与注释XML文件路径相同。
https://stackoverflow.com/questions/57338428
复制相似问题