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
c8943f5d
Commit
c8943f5d
authored
6 years ago
by
Anjith GEORGE
Browse files
Options
Downloads
Patches
Plain Diff
Adds more unit tests for trainers with CV and fuixed a typo
parent
90453ad1
No related branches found
No related tags found
1 merge request
!22
Cross validation
Pipeline
#27603
passed
6 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/learn/pytorch/architectures/FASNet.py
+1
-1
1 addition, 1 deletion
bob/learn/pytorch/architectures/FASNet.py
bob/learn/pytorch/test/test.py
+41
-0
41 additions, 0 deletions
bob/learn/pytorch/test/test.py
with
42 additions
and
1 deletion
bob/learn/pytorch/architectures/FASNet.py
+
1
−
1
View file @
c8943f5d
...
@@ -8,7 +8,7 @@ class FASNet(nn.Module):
...
@@ -8,7 +8,7 @@ class FASNet(nn.Module):
"""
PyTorch Reimplementation of Lucena, Oeslle, et al.
"
Transfer learning using
"""
PyTorch Reimplementation of Lucena, Oeslle, et al.
"
Transfer learning using
convolutional neural networks for face anti-spoofing.
"
convolutional neural networks for face anti-spoofing.
"
International Conference Image Analysis and Recognition. Springer, Cham, 2017.
International Conference Image Analysis and Recognition. Springer, Cham, 2017.
eferenced from keras implementation: https://github.com/OeslleLucena/FASNet
R
eferenced from keras implementation: https://github.com/OeslleLucena/FASNet
Attributes:
Attributes:
pretrained: bool
pretrained: bool
...
...
This diff is collapsed.
Click to expand it.
bob/learn/pytorch/test/test.py
+
41
−
0
View file @
c8943f5d
...
@@ -239,6 +239,27 @@ def test_MCCNNtrainer():
...
@@ -239,6 +239,27 @@ def test_MCCNNtrainer():
os
.
remove
(
'
model_1_0.pth
'
)
os
.
remove
(
'
model_1_0.pth
'
)
def
test_MCCNNtrainer_cv
():
from
..architectures
import
MCCNN
net
=
MCCNN
(
num_channels
=
4
)
dataloader
=
{}
dataloader
[
'
train
'
]
=
torch
.
utils
.
data
.
DataLoader
(
DummyDataSetMCCNN
(),
batch_size
=
32
,
shuffle
=
True
)
dataloader
[
'
val
'
]
=
torch
.
utils
.
data
.
DataLoader
(
DummyDataSetMCCNN
(),
batch_size
=
32
,
shuffle
=
True
)
from
..trainers
import
MCCNNTrainer
trainer
=
MCCNNTrainer
(
net
,
verbosity_level
=
3
,
do_crossvalidation
=
True
)
trainer
.
train
(
dataloader
,
n_epochs
=
1
,
output_dir
=
'
.
'
)
import
os
assert
os
.
path
.
isfile
(
'
model_1_0.pth
'
)
assert
os
.
path
.
isfile
(
'
model_100_0.pth
'
)
# the best model
os
.
remove
(
'
model_1_0.pth
'
)
os
.
remove
(
'
model_100_0.pth
'
)
class
DummyDataSetFASNet
(
Dataset
):
class
DummyDataSetFASNet
(
Dataset
):
def
__init__
(
self
):
def
__init__
(
self
):
pass
pass
...
@@ -268,6 +289,26 @@ def test_FASNettrainer():
...
@@ -268,6 +289,26 @@ def test_FASNettrainer():
os
.
remove
(
'
model_1_0.pth
'
)
os
.
remove
(
'
model_1_0.pth
'
)
def
test_FASNettrainer_cv
():
from
..architectures
import
FASNet
net
=
FASNet
()
dataloader
=
{}
dataloader
[
'
train
'
]
=
torch
.
utils
.
data
.
DataLoader
(
DummyDataSetFASNet
(),
batch_size
=
32
,
shuffle
=
True
)
dataloader
[
'
val
'
]
=
torch
.
utils
.
data
.
DataLoader
(
DummyDataSetFASNet
(),
batch_size
=
32
,
shuffle
=
True
)
from
..trainers
import
FASNetTrainer
trainer
=
FASNetTrainer
(
net
,
verbosity_level
=
3
,
do_crossvalidation
=
True
)
trainer
.
train
(
dataloader
,
n_epochs
=
1
,
output_dir
=
'
.
'
)
import
os
assert
os
.
path
.
isfile
(
'
model_1_0.pth
'
)
assert
os
.
path
.
isfile
(
'
model_100_0.pth
'
)
os
.
remove
(
'
model_1_0.pth
'
)
os
.
remove
(
'
model_100_0.pth
'
)
class
DummyDataSetGAN
(
Dataset
):
class
DummyDataSetGAN
(
Dataset
):
def
__init__
(
self
):
def
__init__
(
self
):
pass
pass
...
...
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