Commit c9fc514c authored by Matt Clarkson's avatar Matt Clarkson

Issue #2: Labelbox seems to timeout, make script re-runnable.

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