Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.bio.face
Manage
Activity
Members
Labels
Plan
Issues
24
Issue boards
Milestones
Code
Merge requests
5
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Show more breadcrumbs
bob
bob.bio.face
Merge requests
!152
Resolve "Pytorch device is not followed in embeddings"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Pytorch device is not followed in embeddings"
68-pytorch-device-is-not-followed-in-embeddings
into
master
Overview
2
Commits
1
Pipelines
2
Changes
1
Merged
Manuel Günther
requested to merge
68-pytorch-device-is-not-followed-in-embeddings
into
master
3 years ago
Overview
2
Commits
1
Pipelines
2
Changes
1
Expand
Closes
#68 (closed)
Edited
3 years ago
by
Manuel Günther
👍
0
👎
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
726dbe21
1 commit,
3 years ago
1 file
+
3
−
10
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
bob/bio/face/embeddings/pytorch.py
+
3
−
10
Options
@@ -56,7 +56,7 @@ class PyTorchModel(TransformerMixin, BaseEstimator):
self
.
model
=
None
self
.
preprocessor
=
preprocessor
self
.
memory_demanding
=
memory_demanding
self
.
device
=
device
self
.
device
=
torch
.
device
(
device
or
"
cuda
"
if
torch
.
cuda
.
is_available
()
else
"
cpu
"
)
def
transform
(
self
,
X
):
"""
__call__(image) -> feature
@@ -110,16 +110,9 @@ class PyTorchModel(TransformerMixin, BaseEstimator):
def
_more_tags
(
self
):
return
{
"
stateless
"
:
True
,
"
requires_fit
"
:
False
}
def
place_model_on_device
(
self
,
device
=
None
):
import
torch
if
device
is
None
:
device
=
torch
.
device
(
"
cuda
"
if
torch
.
cuda
.
is_available
()
else
"
cpu
"
)
self
.
device
=
device
def
place_model_on_device
(
self
):
if
self
.
model
is
not
None
:
self
.
model
.
to
(
device
)
self
.
model
.
to
(
self
.
device
)
class
AFFFE_2021
(
PyTorchModel
):
Loading