繁体   English   中英

运行预训练 ImageAI 模型的问题

[英]Problem with running a pre-trained ImageAI model

我正在运行代码以学习如何从这篇文章中教授 AI/ML 进行对象检测: https : //medium.com/deepquestai/train-object-detection-ai-with-6-lines-of-code-6d087063f6ff (非常好的一个顺便说一句;-)

我下载了预训练模型并在 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'

由于图像文件夹中不存在训练和验证文件夹注释 XML 图像路径,我发现了类似的错误。 检查图像名称是否与您的注释 XML 文件路径相同。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM