首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行预先训练的ImageAI模型时出现的问题

运行预先训练的ImageAI模型时出现的问题
EN

Stack Overflow用户
提问于 2019-08-03 12:45:46
回答 1查看 690关注 0票数 1

我正在运行代码来学习如何从本文中教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

代码语言:javascript
复制
'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,但没有找到答案。

代码语言:javascript
复制
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"])
代码语言:javascript
复制
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'
EN

回答 1

Stack Overflow用户

发布于 2019-12-01 17:24:41

我发现了这个类似的错误,原因是火车和验证文件夹注释XML图像路径在图像文件夹中不存在。检查图像名称是否与注释XML文件路径相同。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57338428

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档