Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
emoca
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Symeonidis-Herzig, Alexandre (PG/R - Comp Sci & Elec Eng)
emoca
Commits
b2f61c7b
Commit
b2f61c7b
authored
2 years ago
by
rdanecek
Browse files
Options
Downloads
Patches
Plain Diff
Pull missing changes from develop
parent
6d1db0a7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gdl/datasets/IO.py
+52
-0
52 additions, 0 deletions
gdl/datasets/IO.py
with
52 additions
and
0 deletions
gdl/datasets/IO.py
+
52
−
0
View file @
b2f61c7b
...
...
@@ -20,11 +20,63 @@ All rights reserved.
import
pickle
as
pkl
import
compress_pickle
as
cpkl
import
hickle
as
hkl
from
pathlib
import
Path
import
numpy
as
np
from
timeit
import
default_timer
as
timer
def
load_reconstruction_list
(
filename
):
reconstructions
=
hkl
.
load
(
filename
)
return
reconstructions
def
save_reconstruction_list
(
filename
,
reconstructions
):
hkl
.
dump
(
reconstructions
,
filename
)
def
load_emotion_list
(
filename
):
emotions
=
hkl
.
load
(
filename
)
return
emotions
def
save_emotion_list
(
filename
,
emotions
):
hkl
.
dump
(
emotions
,
filename
)
def
save_segmentation_list
(
filename
,
seg_images
,
seg_types
,
seg_names
):
with
open
(
filename
,
"
wb
"
)
as
f
:
# for some reason compressed pickle can only load one object (EOF bug)
# so put it in the list
cpkl
.
dump
([
seg_types
,
seg_images
,
seg_names
],
f
,
compression
=
'
gzip
'
)
# pkl.dump(seg_type, f)
# pkl.dump(seg_image, f)
def
load_segmentation_list
(
filename
):
try
:
with
open
(
filename
,
"
rb
"
)
as
f
:
seg
=
cpkl
.
load
(
f
,
compression
=
'
gzip
'
)
seg_types
=
seg
[
0
]
seg_images
=
seg
[
1
]
seg_names
=
seg
[
2
]
except
EOFError
as
e
:
print
(
f
"
Error loading segmentation list:
{
filename
}
"
)
raise
e
return
seg_images
,
seg_types
,
seg_names
def
load_segmentation
(
filename
):
with
open
(
filename
,
"
rb
"
)
as
f
:
seg
=
cpkl
.
load
(
f
,
compression
=
'
gzip
'
)
seg_type
=
seg
[
0
]
seg_image
=
seg
[
1
]
# seg_type = pkl.load(f)
# seg_image = pkl.load(f)
return
seg_image
,
seg_type
def
save_segmentation
(
filename
,
seg_image
,
seg_type
):
with
open
(
filename
,
"
wb
"
)
as
f
:
# for some reason compressed pickle can only load one object (EOF bug)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment