CreateML fixes (#906)

Support createML format
This commit is contained in:
s_teja
2022-07-05 22:48:10 +02:00
committed by GitHub
parent eb603c29e1
commit 5bc7fb9a9c
4 changed files with 35 additions and 5 deletions
+7 -3
View File
@@ -32,6 +32,7 @@ class CreateMLWriter:
output_image_dict = {
"image": self.filename,
"verified": self.verified,
"annotations": []
}
@@ -107,12 +108,15 @@ class CreateMLReader:
with open(self.json_path, "r") as file:
input_data = file.read()
output_dict = json.loads(input_data)
self.verified = True
# Returns a list
output_list = json.loads(input_data)
if output_list:
self.verified = output_list[0].get("verified", False)
if len(self.shapes) > 0:
self.shapes = []
for image in output_dict:
for image in output_list:
if image["image"] == self.filename:
for shape in image["annotations"]:
self.add_shape(shape["label"], shape["coordinates"])
+1
View File
@@ -48,6 +48,7 @@ class LabelFile(object):
image_shape, shapes, filename, local_img_path=image_path)
writer.verified = self.verified
writer.write()
return
def save_pascal_voc_format(self, filename, shapes, image_path, image_data,