Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.pytorch
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.learn.pytorch
Commits
f979eb7d
Commit
f979eb7d
authored
6 years ago
by
Olegs NIKISINS
Browse files
Options
Downloads
Patches
Plain Diff
Fixed the map_labels in the utils, fixing the unit tests
parent
720dd3ce
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!6
autoencoders pretraining using RGB faces
Pipeline
#26193
passed
6 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/learn/pytorch/datasets/utils.py
+8
-8
8 additions, 8 deletions
bob/learn/pytorch/datasets/utils.py
with
8 additions
and
8 deletions
bob/learn/pytorch/datasets/utils.py
+
8
−
8
View file @
f979eb7d
...
...
@@ -26,7 +26,7 @@ class FaceCropper():
cropped
=
self
.
face_cropper
(
sample
[
'
image
'
],
sample
[
'
eyes
'
])
sample
[
'
image
'
]
=
cropped
return
sample
class
RollChannels
(
object
):
"""
...
...
@@ -41,7 +41,7 @@ class RollChannels(object):
class
ToTensor
(
object
):
def
__init__
(
self
):
self
.
op
=
transforms
.
ToTensor
()
def
__call__
(
self
,
sample
):
sample
[
'
image
'
]
=
self
.
op
(
sample
[
'
image
'
])
return
sample
...
...
@@ -70,14 +70,14 @@ class Resize(object):
def
map_labels
(
raw_labels
,
start_index
=
0
):
"""
Map the ID label to [0 - # of IDs]
Map the ID label to [0 - # of IDs]
"""
possible_labels
=
list
(
set
(
raw_labels
))
labels
=
numpy
.
array
(
raw_labels
)
for
i
in
range
(
len
(
possible_labels
)):
l
=
possible_labels
[
i
]
labels
[
numpy
.
where
(
labels
==
l
)[
0
]]
=
i
+
start_index
labels
[
numpy
.
where
(
labels
==
l
)[
0
]
[
0
]
]
=
i
+
start_index
# -----
# map back to native int, resolve the problem with dataset concatenation
...
...
@@ -86,7 +86,7 @@ def map_labels(raw_labels, start_index=0):
labels_int
=
[]
for
i
in
range
(
len
(
labels
)):
labels_int
.
append
(
labels
[
i
].
item
())
return
labels_int
...
...
@@ -105,12 +105,12 @@ class ConcatDataset(Dataset):
The list of datasets (as torch.utils.data.Dataset)
"""
def
__init__
(
self
,
datasets
):
self
.
transform
=
datasets
[
0
].
transform
self
.
data_files
=
sum
((
d
.
data_files
for
d
in
datasets
),
[])
self
.
pose_labels
=
sum
((
d
.
pose_labels
for
d
in
datasets
),
[])
self
.
id_labels
=
sum
((
d
.
id_labels
for
d
in
datasets
),
[])
def
__len__
(
self
):
"""
return the length of the dataset (i.e. nb of examples)
...
...
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