@@ -104,21 +104,22 @@ def dict_to_tf_example(data,
104
104
truncated = []
105
105
poses = []
106
106
difficult_obj = []
107
- for obj in data ['object' ]:
108
- difficult = bool (int (obj ['difficult' ]))
109
- if ignore_difficult_instances and difficult :
110
- continue
111
-
112
- difficult_obj .append (int (difficult ))
113
-
114
- xmin .append (float (obj ['bndbox' ]['xmin' ]) / width )
115
- ymin .append (float (obj ['bndbox' ]['ymin' ]) / height )
116
- xmax .append (float (obj ['bndbox' ]['xmax' ]) / width )
117
- ymax .append (float (obj ['bndbox' ]['ymax' ]) / height )
118
- classes_text .append (obj ['name' ].encode ('utf8' ))
119
- classes .append (label_map_dict [obj ['name' ]])
120
- truncated .append (int (obj ['truncated' ]))
121
- poses .append (obj ['pose' ].encode ('utf8' ))
107
+ if data .has_key ('object' ):
108
+ for obj in data ['object' ]:
109
+ difficult = bool (int (obj ['difficult' ]))
110
+ if ignore_difficult_instances and difficult :
111
+ continue
112
+
113
+ difficult_obj .append (int (difficult ))
114
+
115
+ xmin .append (float (obj ['bndbox' ]['xmin' ]) / width )
116
+ ymin .append (float (obj ['bndbox' ]['ymin' ]) / height )
117
+ xmax .append (float (obj ['bndbox' ]['xmax' ]) / width )
118
+ ymax .append (float (obj ['bndbox' ]['ymax' ]) / height )
119
+ classes_text .append (obj ['name' ].encode ('utf8' ))
120
+ classes .append (label_map_dict [obj ['name' ]])
121
+ truncated .append (int (obj ['truncated' ]))
122
+ poses .append (obj ['pose' ].encode ('utf8' ))
122
123
123
124
example = tf .train .Example (features = tf .train .Features (feature = {
124
125
'image/height' : dataset_util .int64_feature (height ),
0 commit comments