提交 0dd51c13 编写于 作者: J Justin Ellis 提交者: Kentaro Wada

Fixed bug in draw_json and json_to_dataset

上级 e70de8c2
...@@ -2,8 +2,13 @@ ...@@ -2,8 +2,13 @@
import argparse import argparse
import json import json
import os
import sys
import base64
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
PY2 = sys.version_info[0] == 2
from labelme import utils from labelme import utils
...@@ -16,7 +21,14 @@ def main(): ...@@ -16,7 +21,14 @@ def main():
data = json.load(open(json_file)) data = json.load(open(json_file))
img = utils.img_b64_to_arr(data['imageData']) if data['imageData'] is not None:
imageData = data['imageData']
else:
imagePath = os.path.join(os.path.dirname(json_file), data['imagePath'])
with open(imagePath, 'rb') as f:
imageData = f.read()
imageData = base64.b64encode(imageData).decode('utf-8')
img = utils.img_b64_to_arr(imageData)
label_name_to_value = {'_background_': 0} label_name_to_value = {'_background_': 0}
for shape in data['shapes']: for shape in data['shapes']:
......
...@@ -2,6 +2,7 @@ import argparse ...@@ -2,6 +2,7 @@ import argparse
import json import json
import os import os
import os.path as osp import os.path as osp
import base64
import warnings import warnings
import PIL.Image import PIL.Image
...@@ -32,7 +33,15 @@ def main(): ...@@ -32,7 +33,15 @@ def main():
data = json.load(open(json_file)) data = json.load(open(json_file))
img = utils.img_b64_to_arr(data['imageData']) if data['imageData'] is not None:
imageData = data['imageData']
else:
imagePath = os.path.join(os.path.dirname(json_file), data['imagePath'])
with open(imagePath, 'rb') as f:
imageData = f.read()
imageData = base64.b64encode(imageData).decode('utf-8')
img = utils.img_b64_to_arr(imageData)
label_name_to_value = {'_background_': 0} label_name_to_value = {'_background_': 0}
for shape in data['shapes']: for shape in data['shapes']:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册