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
46fc1f92
Commit
46fc1f92
authored
6 years ago
by
Guillaume HEUSCH
Browse files
Options
Downloads
Patches
Plain Diff
[utils] simplify the map_labels function
parent
77b652ca
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!9
Light cnn
Pipeline
#26377
passed
6 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/learn/pytorch/datasets/casia_webface.py
+2
-1
2 additions, 1 deletion
bob/learn/pytorch/datasets/casia_webface.py
bob/learn/pytorch/datasets/utils.py
+5
-5
5 additions, 5 deletions
bob/learn/pytorch/datasets/utils.py
with
7 additions
and
6 deletions
bob/learn/pytorch/datasets/casia_webface.py
+
2
−
1
View file @
46fc1f92
...
@@ -55,9 +55,10 @@ class CasiaWebFaceDataset(Dataset):
...
@@ -55,9 +55,10 @@ class CasiaWebFaceDataset(Dataset):
subject
=
int
(
path
[
-
1
])
subject
=
int
(
path
[
-
1
])
self
.
data_files
.
append
(
os
.
path
.
join
(
root
,
name
))
self
.
data_files
.
append
(
os
.
path
.
join
(
root
,
name
))
id_labels
.
append
(
subject
)
id_labels
.
append
(
subject
)
self
.
id_labels
=
map_labels
(
id_labels
,
start_index
)
self
.
id_labels
=
map_labels
(
id_labels
,
start_index
)
def
__len__
(
self
):
def
__len__
(
self
):
"""
Returns the length of the dataset (i.e. nb of examples)
"""
Returns the length of the dataset (i.e. nb of examples)
...
...
This diff is collapsed.
Click to expand it.
bob/learn/pytorch/datasets/utils.py
+
5
−
5
View file @
46fc1f92
...
@@ -97,12 +97,12 @@ def map_labels(raw_labels, start_index=0):
...
@@ -97,12 +97,12 @@ def map_labels(raw_labels, start_index=0):
# map back to native int, resolve the problem with dataset concatenation
# map back to native int, resolve the problem with dataset concatenation
# it does: line 78 is now ok
# it does: line 78 is now ok
# for some reason, it was not working when the type of id labels were numpy.int64 ...
# for some reason, it was not working when the type of id labels were numpy.int64 ...
labels_int
=
[]
#labels_int = []
for
i
in
range
(
len
(
labels
)):
#for i in range(len(labels)):
labels_int
.
append
(
labels
[
i
].
item
())
# labels_int.append(labels[i].item())
return
labels_int
#return labels_int
return
labels
from
torch.utils.data
import
Dataset
from
torch.utils.data
import
Dataset
import
bob.io.base
import
bob.io.base
...
...
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