Commit 1d19326b authored by Matt Clarkson's avatar Matt Clarkson

Fix path issues.

parent ca939d23
......@@ -31,6 +31,7 @@ def run_labelbox_json_export(json_file, output_dir, output_format):
for sample in decoded_data:
dataset_name = sample['Dataset Name']
external_id = sample['External ID']
labeled_data = sample['Labeled Data']
basename = os.path.basename(external_id)
filename_no_extension = os.path.splitext(basename)[0]
objects = sample['Label']['objects']
......@@ -39,10 +40,25 @@ def run_labelbox_json_export(json_file, output_dir, output_format):
if not os.path.exists(dir_name):
os.makedirs(dir_name)
images_name = os.path.join(dir_name, 'images')
if not os.path.exists(images_name):
os.makedirs(images_name)
image_file = os.path.join(images_name,
external_id)
if not os.path.exists(image_file):
six.print_("downloading image to:" + image_file)
urllib.request.urlretrieve(labeled_data, image_file)
masks_name = os.path.join(dir_name, 'masks')
if not os.path.exists(masks_name):
os.makedirs(masks_name)
for obj in objects:
instance_uri = obj['instanceURI']
value = obj['value']
file_name = os.path.join(dir_name,
file_name = os.path.join(masks_name,
filename_no_extension
+ '_' + value + '.bmp')
......@@ -55,7 +71,7 @@ def run_labelbox_json_export(json_file, output_dir, output_format):
else:
if output_format == 'grey':
output_file_name = os.path.join(dir_name,
output_file_name = os.path.join(masks_name,
filename_no_extension
+ '_' + value + '.png')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment