I have a mistake that I can't solve.. have you got an advice?
polygons = [r['shape_attributes'] for r in a['regions'].values()]
AttributeError: 'list' object has no attribute 'values'
If I understand well : a is a dictionnary but a['regions'] is a list of dictionnaries.
Indeed a 'list' object has no attribute 'values'. If you want to loop over the values of your list you need to use this syntax :
polygons = [region['shape_attributes'] for region in a['regions']]
TypeError: string indices must be integers{ 'filename': '28503151_5b5b7ec140_b.jpg', 'regions': { '0': { 'region_attributes': {}, 'shape_attributes': { 'all_points_x': [...], 'all_points_y': [...], 'name': 'polygon'}}, ... more regions ... }, 'size': 100202 }AttributeError: 'list' object has no attribute 'items'you need for each annotation-img one dictionary, that's the way Mask RCNN works.
{
"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
},
you need to add your load_funcion and your json file, Otherwise it's hard to help you.
I really want to know the result if you print this line.
annotations = list(annotations1.values())
a.get('regions'), maybe it's better ? Because I'm using a dict .