Turi Create中的guide for Object Detection不包括设置数据,包括如何附加“annotations”类别。在
我所做的是创建一个单独的annotations
文件,如下所示:
{
"1.jpg": {
"type": "rectangle",
"coordinates": {
"height": 97,
"width": 243,
"x": 4224,
"y": 1821
},
"label": "cw"
}
然后,我使用load_images
设置我的数据,这个文件:
这很好,如果我打印data
,我会得到这样的结果:
+-------------------------------+---------------------------+
| path | image |
+-------------------------------+---------------------------+
| /Users/Andrew/Code/turi/cw... | Height: 3816 Width: 11056 |
| /Users/Andrew/Code/turi/cw... | Height: 3888 Width: 10672 |
| /Users/Andrew/Code/turi/cw... | Height: 3656 Width: 9700 |
| /Users/Andrew/Code/turi/cw... | Height: 3872 Width: 8280 |
+-------------------------------+---------------------------+
+-------------------------------+
| annotations |
+-------------------------------+
| {'type': 'rectangle', 'coo... |
| {'type': 'rectangle', 'coo... |
| {'type': 'rectangle', 'coo... |
| {'type': 'rectangle', 'coo... |
+-------------------------------+
我不知道为什么在控制台中将它分成两行-可能只是因为大小原因。在
因此,我进入了《对象检测指南》中的这一行,它打算将应用于数据的注释可视化:
tc.object_detector.util.draw_bounding_boxes(data["image"], data["annotations"])
运行此程序时,控制台中出现以下错误:
Traceback (most recent call last):
File "app.py", line 62, in <module>
load_data(bounds)
File "app.py", line 23, in load_data
tc.object_detector.util.draw_bounding_boxes(data["image"], data["annotations"])
File "/Users/Andrew/turi/lib/python2.7/site-packages/turicreate/toolkits/object_detector/util/_visualization.py", line 139, in draw_bounding_boxes
.apply(draw_single_image))
File "/Users/Andrew/turi/lib/python2.7/site-packages/turicreate/data_structures/sframe.py", line 2463, in apply
dryrun = [fn(row) for row in test_sf]
File "/Users/Andrew/turi/lib/python2.7/site-packages/turicreate/toolkits/object_detector/util/_visualization.py", line 124, in draw_single_image
_annotate_image(pil_img, anns, confidence_threshold=confidence_threshold)
File "/Users/Andrew/turi/lib/python2.7/site-packages/turicreate/toolkits/object_detector/util/_visualization.py", line 49, in _annotate_image
for ann in reversed(anns):
TypeError: argument to reversed() must be a sequence
另外,如果我把它说出来,然后继续做:
model = tc.object_detector.create(data, feature="image", annotations="annotations")
我得到了一个错误:
Traceback (most recent call last):
File "app.py", line 65, in <module>
learn()
File "app.py", line 37, in learn
model = tc.object_detector.create(data, feature="image", annotations="annotations")
File "/Users/Andrew/turi/lib/python2.7/site-packages/turicreate/toolkits/object_detector/object_detector.py", line 170, in create
require_annotations=True)
File "/Users/Andrew/turi/lib/python2.7/site-packages/turicreate/toolkits/object_detector/object_detector.py", line 66, in _raise_error_if_not_detection_sframe
raise _ToolkitError("Annotations column must contain lists")
turicreate.toolkits._main.ToolkitError: Annotations column must contain lists
大概是我把annotations列设置得不正确。在
annotations
列缺少左括号和右括号。如果您查看本教程中的可视化输出,您将看到每个注释的开头都有一个左括号(…并且可能在末尾有一个右括号)。在现在不知道怎么解决这个问题。但当我得到解决方案时会尝试发布。在
相关问题 更多 >
编程相关推荐