From 927c86386905dc9f157cbfb610bc2b452a045b8f Mon Sep 17 00:00:00 2001 From: hqm Date: Wed, 15 Sep 2021 16:59:26 -0400 Subject: [PATCH 1/2] don't barf if image data not in json file --- labelme2coco.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/labelme2coco.py b/labelme2coco.py index ab60ecf..9f70140 100644 --- a/labelme2coco.py +++ b/labelme2coco.py @@ -48,9 +48,14 @@ def data_transfer(self): def image(self, data, num): image = {} - img = utils.img_b64_to_arr(data["imageData"]) - height, width = img.shape[:2] - img = None + binhex = data.get("imageData") + if binhex: + img = utils.img_b64_to_arr() + height, width = img.shape[:2] + img = None + else: + height = data['imageHeight'] + width = data['imageWidth'] image["height"] = height image["width"] = width image["id"] = num From 71cf97c9218b29b815be0a08a151174071ead757 Mon Sep 17 00:00:00 2001 From: hqm Date: Wed, 15 Sep 2021 17:34:50 -0400 Subject: [PATCH 2/2] forgot the arg to decode binhex method --- labelme2coco.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labelme2coco.py b/labelme2coco.py index 9f70140..3fd3dd1 100644 --- a/labelme2coco.py +++ b/labelme2coco.py @@ -50,7 +50,7 @@ def image(self, data, num): image = {} binhex = data.get("imageData") if binhex: - img = utils.img_b64_to_arr() + img = utils.img_b64_to_arr(binhex) height, width = img.shape[:2] img = None else: