我有一个我无法解决的错误..你有建议吗?
polygons = [r['shape_attributes'] for r in a['regions'].values()]
AttributeError:“列表”对象没有属性“值”
答案 0 :(得分:1)
如果我很好理解:a
是词典,而a['regions']
是词典列表。
实际上,“列表”对象没有属性“值”。 如果要遍历列表的值,则需要使用以下语法:
polygons = [region['shape_attributes'] for region in a['regions']]
答案 1 :(得分:0)
每个批注-img需要一个字典,这就是 Mask RCNN 的工作方式。
{
"IMG_20180413_091455.jpg1231831": {
"base64_img_data": "",
"file_attributes": {},
"filename": "IMG_20180413_091455.jpg",
"fileref": "",
"regions": {
"0": {
"region_attributes": {
"damage": "damage"
},
"shape_attributes": {
"all_points_x": [
2388,
2586,
2645,
2655,
2635,
2497,
2363,
2328,
2388
],
"all_points_y": [
1100,
1129,
1189,
1243,
1298,
1298,
1229,
1159,
1100
],
"name": "polygon"
}
}
},
"size": 1231831
},
您需要添加load_funcion和json文件,否则很难为您提供帮助。
如果您打印此行,我真的很想知道结果。
annotations = list(annotations1.values())