Commit b7a381af authored by Matt Clarkson's avatar Matt Clarkson

Merge branch '2-make-rerunnable'

parents a3a24fc4 c9fc514c
Pipeline #3877 passed with stages
in 9 minutes
...@@ -23,6 +23,11 @@ def run_labelbox_json_export(json_file, output_dir, output_format): ...@@ -23,6 +23,11 @@ def run_labelbox_json_export(json_file, output_dir, output_format):
with open(json_file) as file: with open(json_file) as file:
data = file.read() data = file.read()
decoded_data = json.loads(data) decoded_data = json.loads(data)
six.print_("There are:"
+ str(len(decoded_data))
+ " samples to download.")
for sample in decoded_data: for sample in decoded_data:
dataset_name = sample['Dataset Name'] dataset_name = sample['Dataset Name']
external_id = sample['External ID'] external_id = sample['External ID']
...@@ -40,24 +45,36 @@ def run_labelbox_json_export(json_file, output_dir, output_format): ...@@ -40,24 +45,36 @@ def run_labelbox_json_export(json_file, output_dir, output_format):
file_name = os.path.join(dir_name, file_name = os.path.join(dir_name,
filename_no_extension filename_no_extension
+ '_' + value + '.bmp') + '_' + value + '.bmp')
six.print_("writing to:" + file_name)
if not os.path.exists(file_name):
six.print_("downloading to:" + file_name)
urllib.request.urlretrieve(instance_uri, file_name) urllib.request.urlretrieve(instance_uri, file_name)
if not os.path.exists(file_name):
six.print_("ERROR: Failed to download:" + file_name)
else:
if output_format == 'grey': if output_format == 'grey':
image = cv2.imread(file_name)
grey = cv2.cvtColor(image, cv2.COLOR_BGRA2GRAY)
file_name = os.path.join(dir_name, file_name = os.path.join(dir_name,
filename_no_extension filename_no_extension
+ '_' + value + '.png') + '_' + value + '.png')
if not os.path.exists(file_name):
image = cv2.imread(file_name)
grey = cv2.cvtColor(image, cv2.COLOR_BGRA2GRAY)
cv2.imwrite(file_name, grey) cv2.imwrite(file_name, grey)
six.print_("writing to:" + file_name) six.print_("writing to:" + file_name)
elif output_format == 'rgb': elif output_format == 'rgb':
image = cv2.imread(file_name)
rgb = cv2.cvtColor(image, cv2.COLOR_BGRA2BGR)
file_name = os.path.join(dir_name, file_name = os.path.join(dir_name,
filename_no_extension filename_no_extension
+ '_' + value + '.png') + '_' + value + '.png')
if not os.path.exists(file_name):
image = cv2.imread(file_name)
rgb = cv2.cvtColor(image, cv2.COLOR_BGRA2BGR)
cv2.imwrite(file_name, rgb) cv2.imwrite(file_name, rgb)
six.print_("writing to:" + file_name) six.print_("writing to:" + file_name)
six.print_("Done")
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