Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
LabelboxUtils
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
WEISS
Software Repositories
LabelboxUtils
Commits
c9fc514c
Commit
c9fc514c
authored
Dec 20, 2019
by
Matt Clarkson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2
: Labelbox seems to timeout, make script re-runnable.
parent
a3a24fc4
Pipeline
#3875
passed with stages
in 6 minutes and 57 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
21 deletions
+38
-21
labelboxutils/ui/labelbox_export_json_app.py
labelboxutils/ui/labelbox_export_json_app.py
+38
-21
No files found.
labelboxutils/ui/labelbox_export_json_app.py
View file @
c9fc514c
...
...
@@ -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
)
urllib
.
request
.
urlretrieve
(
instance_uri
,
file_name
)
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'
)
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'
)
cv2
.
imwrite
(
file_name
,
rgb
)
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'
:
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'
:
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"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment