Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
115d2eb7
Unverified
Commit
115d2eb7
authored
May 21, 2019
by
Francisco Massa
Committed by
GitHub
May 21, 2019
Browse files
Add pretrained arg to reference scripts (#935)
Allows for easily evaluating the pre-trained models in the modelzoo
parent
6e5599e4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
3 deletions
+24
-3
references/classification/train.py
references/classification/train.py
+7
-1
references/detection/train.py
references/detection/train.py
+8
-1
references/segmentation/train.py
references/segmentation/train.py
+9
-1
No files found.
references/classification/train.py
View file @
115d2eb7
...
@@ -144,7 +144,7 @@ def main(args):
...
@@ -144,7 +144,7 @@ def main(args):
sampler
=
test_sampler
,
num_workers
=
args
.
workers
,
pin_memory
=
True
)
sampler
=
test_sampler
,
num_workers
=
args
.
workers
,
pin_memory
=
True
)
print
(
"Creating model"
)
print
(
"Creating model"
)
model
=
torchvision
.
models
.
__dict__
[
args
.
model
]()
model
=
torchvision
.
models
.
__dict__
[
args
.
model
](
pretrained
=
args
.
pretrained
)
model
.
to
(
device
)
model
.
to
(
device
)
if
args
.
distributed
and
args
.
sync_bn
:
if
args
.
distributed
and
args
.
sync_bn
:
model
=
torch
.
nn
.
SyncBatchNorm
.
convert_sync_batchnorm
(
model
)
model
=
torch
.
nn
.
SyncBatchNorm
.
convert_sync_batchnorm
(
model
)
...
@@ -242,6 +242,12 @@ def parse_args():
...
@@ -242,6 +242,12 @@ def parse_args():
help
=
"Only test the model"
,
help
=
"Only test the model"
,
action
=
"store_true"
,
action
=
"store_true"
,
)
)
parser
.
add_argument
(
"--pretrained"
,
dest
=
"pretrained"
,
help
=
"Use pre-trained models from the modelzoo"
,
action
=
"store_true"
,
)
# distributed training parameters
# distributed training parameters
parser
.
add_argument
(
'--world-size'
,
default
=
1
,
type
=
int
,
parser
.
add_argument
(
'--world-size'
,
default
=
1
,
type
=
int
,
...
...
references/detection/train.py
View file @
115d2eb7
...
@@ -76,7 +76,8 @@ def main(args):
...
@@ -76,7 +76,8 @@ def main(args):
collate_fn
=
utils
.
collate_fn
)
collate_fn
=
utils
.
collate_fn
)
print
(
"Creating model"
)
print
(
"Creating model"
)
model
=
torchvision
.
models
.
detection
.
__dict__
[
args
.
model
](
num_classes
=
num_classes
)
model
=
torchvision
.
models
.
detection
.
__dict__
[
args
.
model
](
num_classes
=
num_classes
,
pretrained
=
args
.
pretrained
)
model
.
to
(
device
)
model
.
to
(
device
)
model_without_ddp
=
model
model_without_ddp
=
model
...
@@ -156,6 +157,12 @@ if __name__ == "__main__":
...
@@ -156,6 +157,12 @@ if __name__ == "__main__":
help
=
"Only test the model"
,
help
=
"Only test the model"
,
action
=
"store_true"
,
action
=
"store_true"
,
)
)
parser
.
add_argument
(
"--pretrained"
,
dest
=
"pretrained"
,
help
=
"Use pre-trained models from the modelzoo"
,
action
=
"store_true"
,
)
# distributed training parameters
# distributed training parameters
parser
.
add_argument
(
'--world-size'
,
default
=
1
,
type
=
int
,
parser
.
add_argument
(
'--world-size'
,
default
=
1
,
type
=
int
,
...
...
references/segmentation/train.py
View file @
115d2eb7
...
@@ -121,7 +121,9 @@ def main(args):
...
@@ -121,7 +121,9 @@ def main(args):
sampler
=
test_sampler
,
num_workers
=
args
.
workers
,
sampler
=
test_sampler
,
num_workers
=
args
.
workers
,
collate_fn
=
utils
.
collate_fn
)
collate_fn
=
utils
.
collate_fn
)
model
=
torchvision
.
models
.
segmentation
.
__dict__
[
args
.
model
](
num_classes
=
num_classes
,
aux_loss
=
args
.
aux_loss
)
model
=
torchvision
.
models
.
segmentation
.
__dict__
[
args
.
model
](
num_classes
=
num_classes
,
aux_loss
=
args
.
aux_loss
,
pretrained
=
args
.
pretrained
)
model
.
to
(
device
)
model
.
to
(
device
)
if
args
.
distributed
:
if
args
.
distributed
:
model
=
torch
.
nn
.
SyncBatchNorm
.
convert_sync_batchnorm
(
model
)
model
=
torch
.
nn
.
SyncBatchNorm
.
convert_sync_batchnorm
(
model
)
...
@@ -205,6 +207,12 @@ def parse_args():
...
@@ -205,6 +207,12 @@ def parse_args():
help
=
"Only test the model"
,
help
=
"Only test the model"
,
action
=
"store_true"
,
action
=
"store_true"
,
)
)
parser
.
add_argument
(
"--pretrained"
,
dest
=
"pretrained"
,
help
=
"Use pre-trained models from the modelzoo"
,
action
=
"store_true"
,
)
# distributed training parameters
# distributed training parameters
parser
.
add_argument
(
'--world-size'
,
default
=
1
,
type
=
int
,
parser
.
add_argument
(
'--world-size'
,
default
=
1
,
type
=
int
,
help
=
'number of distributed processes'
)
help
=
'number of distributed processes'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment