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
ModelZoo
ResNet50_tensorflow
Commits
f7938e6a
Commit
f7938e6a
authored
May 18, 2021
by
Xianzhi Du
Committed by
A. Unique TensorFlower
May 18, 2021
Browse files
Internal change
PiperOrigin-RevId: 374481243
parent
0d62382b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
42 deletions
+69
-42
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet143_cascadercnn_tpu.yaml
...xperiments/maskrcnn/coco_spinenet143_cascadercnn_tpu.yaml
+4
-3
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet49_cascadercnn_tpu.yaml
...experiments/maskrcnn/coco_spinenet49_cascadercnn_tpu.yaml
+3
-1
official/vision/beta/configs/maskrcnn.py
official/vision/beta/configs/maskrcnn.py
+61
-37
official/vision/beta/configs/maskrcnn_test.py
official/vision/beta/configs/maskrcnn_test.py
+1
-1
No files found.
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet143_casrcnn_tpu.yaml
→
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet143_cas
cade
rcnn_tpu.yaml
View file @
f7938e6a
# Expect to reach: box mAP: 51.6%, mask mAP: 44.5% on COCO
# --experiment_type=cascadercnn_spinenet_coco
# Expect to reach: box mAP: 51.9%, mask mAP: 45.0% on COCO
runtime
:
runtime
:
distribution_strategy
:
'
tpu'
distribution_strategy
:
'
tpu'
mixed_precision_dtype
:
'
bfloat16'
mixed_precision_dtype
:
'
bfloat16'
...
@@ -43,12 +44,12 @@ task:
...
@@ -43,12 +44,12 @@ task:
detection_generator
:
detection_generator
:
pre_nms_top_k
:
1000
pre_nms_top_k
:
1000
trainer
:
trainer
:
train_steps
:
16205
0
train_steps
:
23100
0
optimizer_config
:
optimizer_config
:
learning_rate
:
learning_rate
:
type
:
'
stepwise'
type
:
'
stepwise'
stepwise
:
stepwise
:
boundaries
:
[
148160
,
15742
0
]
boundaries
:
[
219450
,
22638
0
]
values
:
[
0.32
,
0.032
,
0.0032
]
values
:
[
0.32
,
0.032
,
0.0032
]
warmup
:
warmup
:
type
:
'
linear'
type
:
'
linear'
...
...
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet49_casrcnn_tpu.yaml
→
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet49_cas
cade
rcnn_tpu.yaml
View file @
f7938e6a
# --experiment_type=cascadercnn_spinenet_coco
# Expect to reach: box mAP: 46.4%, mask mAP: 40.0% on COCO
runtime
:
runtime
:
distribution_strategy
:
'
tpu'
distribution_strategy
:
'
tpu'
mixed_precision_dtype
:
'
bfloat16'
mixed_precision_dtype
:
'
bfloat16'
...
@@ -48,7 +50,7 @@ trainer:
...
@@ -48,7 +50,7 @@ trainer:
type
:
'
stepwise'
type
:
'
stepwise'
stepwise
:
stepwise
:
boundaries
:
[
219450
,
226380
]
boundaries
:
[
219450
,
226380
]
values
:
[
0.2
8
,
0.02
8
,
0.002
8
]
values
:
[
0.
3
2
,
0.0
3
2
,
0.00
3
2
]
warmup
:
warmup
:
type
:
'
linear'
type
:
'
linear'
linear
:
linear
:
...
...
official/vision/beta/configs/maskrcnn.py
View file @
f7938e6a
...
@@ -233,6 +233,8 @@ def fasterrcnn_resnetfpn_coco() -> cfg.ExperimentConfig:
...
@@ -233,6 +233,8 @@ def fasterrcnn_resnetfpn_coco() -> cfg.ExperimentConfig:
"""COCO object detection with Faster R-CNN."""
"""COCO object detection with Faster R-CNN."""
steps_per_epoch
=
500
steps_per_epoch
=
500
coco_val_samples
=
5000
coco_val_samples
=
5000
train_batch_size
=
64
eval_batch_size
=
8
config
=
cfg
.
ExperimentConfig
(
config
=
cfg
.
ExperimentConfig
(
runtime
=
cfg
.
RuntimeConfig
(
mixed_precision_dtype
=
'bfloat16'
),
runtime
=
cfg
.
RuntimeConfig
(
mixed_precision_dtype
=
'bfloat16'
),
...
@@ -252,16 +254,16 @@ def fasterrcnn_resnetfpn_coco() -> cfg.ExperimentConfig:
...
@@ -252,16 +254,16 @@ def fasterrcnn_resnetfpn_coco() -> cfg.ExperimentConfig:
train_data
=
DataConfig
(
train_data
=
DataConfig
(
input_path
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
'train*'
),
input_path
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
'train*'
),
is_training
=
True
,
is_training
=
True
,
global_batch_size
=
64
,
global_batch_size
=
train_batch_size
,
parser
=
Parser
(
parser
=
Parser
(
aug_rand_hflip
=
True
,
aug_scale_min
=
0.8
,
aug_scale_max
=
1.25
)),
aug_rand_hflip
=
True
,
aug_scale_min
=
0.8
,
aug_scale_max
=
1.25
)),
validation_data
=
DataConfig
(
validation_data
=
DataConfig
(
input_path
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
'val*'
),
input_path
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
'val*'
),
is_training
=
False
,
is_training
=
False
,
global_batch_size
=
8
)),
global_batch_size
=
eval_batch_size
)),
trainer
=
cfg
.
TrainerConfig
(
trainer
=
cfg
.
TrainerConfig
(
train_steps
=
22500
,
train_steps
=
22500
,
validation_steps
=
coco_val_samples
//
8
,
validation_steps
=
coco_val_samples
//
eval_batch_size
,
validation_interval
=
steps_per_epoch
,
validation_interval
=
steps_per_epoch
,
steps_per_loop
=
steps_per_epoch
,
steps_per_loop
=
steps_per_epoch
,
summary_interval
=
steps_per_epoch
,
summary_interval
=
steps_per_epoch
,
...
@@ -300,6 +302,8 @@ def maskrcnn_resnetfpn_coco() -> cfg.ExperimentConfig:
...
@@ -300,6 +302,8 @@ def maskrcnn_resnetfpn_coco() -> cfg.ExperimentConfig:
"""COCO object detection with Mask R-CNN."""
"""COCO object detection with Mask R-CNN."""
steps_per_epoch
=
500
steps_per_epoch
=
500
coco_val_samples
=
5000
coco_val_samples
=
5000
train_batch_size
=
64
eval_batch_size
=
8
config
=
cfg
.
ExperimentConfig
(
config
=
cfg
.
ExperimentConfig
(
runtime
=
cfg
.
RuntimeConfig
(
mixed_precision_dtype
=
'bfloat16'
),
runtime
=
cfg
.
RuntimeConfig
(
mixed_precision_dtype
=
'bfloat16'
),
...
@@ -314,16 +318,16 @@ def maskrcnn_resnetfpn_coco() -> cfg.ExperimentConfig:
...
@@ -314,16 +318,16 @@ def maskrcnn_resnetfpn_coco() -> cfg.ExperimentConfig:
train_data
=
DataConfig
(
train_data
=
DataConfig
(
input_path
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
'train*'
),
input_path
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
'train*'
),
is_training
=
True
,
is_training
=
True
,
global_batch_size
=
64
,
global_batch_size
=
train_batch_size
,
parser
=
Parser
(
parser
=
Parser
(
aug_rand_hflip
=
True
,
aug_scale_min
=
0.8
,
aug_scale_max
=
1.25
)),
aug_rand_hflip
=
True
,
aug_scale_min
=
0.8
,
aug_scale_max
=
1.25
)),
validation_data
=
DataConfig
(
validation_data
=
DataConfig
(
input_path
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
'val*'
),
input_path
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
'val*'
),
is_training
=
False
,
is_training
=
False
,
global_batch_size
=
8
)),
global_batch_size
=
eval_batch_size
)),
trainer
=
cfg
.
TrainerConfig
(
trainer
=
cfg
.
TrainerConfig
(
train_steps
=
22500
,
train_steps
=
22500
,
validation_steps
=
coco_val_samples
//
8
,
validation_steps
=
coco_val_samples
//
eval_batch_size
,
validation_interval
=
steps_per_epoch
,
validation_interval
=
steps_per_epoch
,
steps_per_loop
=
steps_per_epoch
,
steps_per_loop
=
steps_per_epoch
,
summary_interval
=
steps_per_epoch
,
summary_interval
=
steps_per_epoch
,
...
@@ -357,40 +361,50 @@ def maskrcnn_resnetfpn_coco() -> cfg.ExperimentConfig:
...
@@ -357,40 +361,50 @@ def maskrcnn_resnetfpn_coco() -> cfg.ExperimentConfig:
return
config
return
config
@
exp_factory
.
register_config_factory
(
'
c
as
cade
rcnn_
resnetfpn
_coco'
)
@
exp_factory
.
register_config_factory
(
'
m
as
k
rcnn_
spinenet
_coco'
)
def
c
as
cade
rcnn_
resnetfpn
_coco
()
->
cfg
.
ExperimentConfig
:
def
m
as
k
rcnn_
spinenet
_coco
()
->
cfg
.
ExperimentConfig
:
"""COCO object detection with
C
as
cade
R-CNN."""
"""COCO object detection with
M
as
k
R-CNN
with SpineNet backbone
."""
steps_per_epoch
=
500
steps_per_epoch
=
463
coco_val_samples
=
5000
coco_val_samples
=
5000
train_batch_size
=
256
eval_batch_size
=
8
config
=
cfg
.
ExperimentConfig
(
config
=
cfg
.
ExperimentConfig
(
runtime
=
cfg
.
RuntimeConfig
(
mixed_precision_dtype
=
'bfloat16'
),
runtime
=
cfg
.
RuntimeConfig
(
mixed_precision_dtype
=
'bfloat16'
),
task
=
MaskRCNNTask
(
task
=
MaskRCNNTask
(
init_checkpoint
=
'gs://cloud-tpu-checkpoints/vision-2.0/resnet50_imagenet/ckpt-28080'
,
init_checkpoint_modules
=
'backbone'
,
annotation_file
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
annotation_file
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
'instances_val2017.json'
),
'instances_val2017.json'
),
model
=
MaskRCNN
(
model
=
MaskRCNN
(
backbone
=
backbones
.
Backbone
(
type
=
'spinenet'
,
spinenet
=
backbones
.
SpineNet
(
model_id
=
'49'
,
min_level
=
3
,
max_level
=
7
,
)),
decoder
=
decoders
.
Decoder
(
type
=
'identity'
,
identity
=
decoders
.
Identity
()),
anchor
=
Anchor
(
anchor_size
=
3
),
norm_activation
=
common
.
NormActivation
(
use_sync_bn
=
True
),
num_classes
=
91
,
num_classes
=
91
,
input_size
=
[
1024
,
1024
,
3
],
input_size
=
[
640
,
640
,
3
],
include_mask
=
True
,
min_level
=
3
,
roi_sampler
=
ROISampler
(
cascade_iou_thresholds
=
[
0.6
,
0.7
]),
max_level
=
7
,
detection_head
=
DetectionHead
(
include_mask
=
True
),
class_agnostic_bbox_pred
=
True
,
cascade_class_ensemble
=
True
)),
losses
=
Losses
(
l2_weight_decay
=
0.00004
),
losses
=
Losses
(
l2_weight_decay
=
0.00004
),
train_data
=
DataConfig
(
train_data
=
DataConfig
(
input_path
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
'train*'
),
input_path
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
'train*'
),
is_training
=
True
,
is_training
=
True
,
global_batch_size
=
64
,
global_batch_size
=
train_batch_size
,
parser
=
Parser
(
parser
=
Parser
(
aug_rand_hflip
=
True
,
aug_scale_min
=
0.
8
,
aug_scale_max
=
1.25
)),
aug_rand_hflip
=
True
,
aug_scale_min
=
0.
5
,
aug_scale_max
=
2.0
)),
validation_data
=
DataConfig
(
validation_data
=
DataConfig
(
input_path
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
'val*'
),
input_path
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
'val*'
),
is_training
=
False
,
is_training
=
False
,
global_batch_size
=
8
)),
global_batch_size
=
eval_batch_size
)),
trainer
=
cfg
.
TrainerConfig
(
trainer
=
cfg
.
TrainerConfig
(
train_steps
=
2250
0
,
train_steps
=
steps_per_epoch
*
35
0
,
validation_steps
=
coco_val_samples
//
8
,
validation_steps
=
coco_val_samples
//
eval_batch_size
,
validation_interval
=
steps_per_epoch
,
validation_interval
=
steps_per_epoch
,
steps_per_loop
=
steps_per_epoch
,
steps_per_loop
=
steps_per_epoch
,
summary_interval
=
steps_per_epoch
,
summary_interval
=
steps_per_epoch
,
...
@@ -405,30 +419,36 @@ def cascadercnn_resnetfpn_coco() -> cfg.ExperimentConfig:
...
@@ -405,30 +419,36 @@ def cascadercnn_resnetfpn_coco() -> cfg.ExperimentConfig:
'learning_rate'
:
{
'learning_rate'
:
{
'type'
:
'stepwise'
,
'type'
:
'stepwise'
,
'stepwise'
:
{
'stepwise'
:
{
'boundaries'
:
[
15000
,
20000
],
'boundaries'
:
[
'values'
:
[
0.12
,
0.012
,
0.0012
],
steps_per_epoch
*
320
,
steps_per_epoch
*
340
],
'values'
:
[
0.32
,
0.032
,
0.0032
],
}
}
},
},
'warmup'
:
{
'warmup'
:
{
'type'
:
'linear'
,
'type'
:
'linear'
,
'linear'
:
{
'linear'
:
{
'warmup_steps'
:
5
00
,
'warmup_steps'
:
20
00
,
'warmup_learning_rate'
:
0.0067
'warmup_learning_rate'
:
0.0067
}
}
}
}
})),
})),
restrictions
=
[
restrictions
=
[
'task.train_data.is_training != None'
,
'task.train_data.is_training != None'
,
'task.validation_data.is_training != None'
'task.validation_data.is_training != None'
,
'task.model.min_level == task.model.backbone.spinenet.min_level'
,
'task.model.max_level == task.model.backbone.spinenet.max_level'
,
])
])
return
config
return
config
@
exp_factory
.
register_config_factory
(
'
m
as
k
rcnn_spinenet_coco'
)
@
exp_factory
.
register_config_factory
(
'
c
as
cade
rcnn_spinenet_coco'
)
def
m
as
k
rcnn_spinenet_coco
()
->
cfg
.
ExperimentConfig
:
def
c
as
cade
rcnn_spinenet_coco
()
->
cfg
.
ExperimentConfig
:
"""COCO object detection with
M
as
k
R-CNN with SpineNet backbone."""
"""COCO object detection with
C
as
cade
R-CNN with SpineNet backbone."""
steps_per_epoch
=
463
steps_per_epoch
=
463
coco_val_samples
=
5000
coco_val_samples
=
5000
train_batch_size
=
256
eval_batch_size
=
8
config
=
cfg
.
ExperimentConfig
(
config
=
cfg
.
ExperimentConfig
(
runtime
=
cfg
.
RuntimeConfig
(
mixed_precision_dtype
=
'bfloat16'
),
runtime
=
cfg
.
RuntimeConfig
(
mixed_precision_dtype
=
'bfloat16'
),
...
@@ -445,8 +465,12 @@ def maskrcnn_spinenet_coco() -> cfg.ExperimentConfig:
...
@@ -445,8 +465,12 @@ def maskrcnn_spinenet_coco() -> cfg.ExperimentConfig:
)),
)),
decoder
=
decoders
.
Decoder
(
decoder
=
decoders
.
Decoder
(
type
=
'identity'
,
identity
=
decoders
.
Identity
()),
type
=
'identity'
,
identity
=
decoders
.
Identity
()),
roi_sampler
=
ROISampler
(
cascade_iou_thresholds
=
[
0.6
,
0.7
]),
detection_head
=
DetectionHead
(
class_agnostic_bbox_pred
=
True
,
cascade_class_ensemble
=
True
),
anchor
=
Anchor
(
anchor_size
=
3
),
anchor
=
Anchor
(
anchor_size
=
3
),
norm_activation
=
common
.
NormActivation
(
use_sync_bn
=
True
),
norm_activation
=
common
.
NormActivation
(
use_sync_bn
=
True
,
activation
=
'swish'
),
num_classes
=
91
,
num_classes
=
91
,
input_size
=
[
640
,
640
,
3
],
input_size
=
[
640
,
640
,
3
],
min_level
=
3
,
min_level
=
3
,
...
@@ -456,16 +480,16 @@ def maskrcnn_spinenet_coco() -> cfg.ExperimentConfig:
...
@@ -456,16 +480,16 @@ def maskrcnn_spinenet_coco() -> cfg.ExperimentConfig:
train_data
=
DataConfig
(
train_data
=
DataConfig
(
input_path
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
'train*'
),
input_path
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
'train*'
),
is_training
=
True
,
is_training
=
True
,
global_batch_size
=
256
,
global_batch_size
=
train_batch_size
,
parser
=
Parser
(
parser
=
Parser
(
aug_rand_hflip
=
True
,
aug_scale_min
=
0.
5
,
aug_scale_max
=
2.
0
)),
aug_rand_hflip
=
True
,
aug_scale_min
=
0.
1
,
aug_scale_max
=
2.
5
)),
validation_data
=
DataConfig
(
validation_data
=
DataConfig
(
input_path
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
'val*'
),
input_path
=
os
.
path
.
join
(
COCO_INPUT_PATH_BASE
,
'val*'
),
is_training
=
False
,
is_training
=
False
,
global_batch_size
=
8
)),
global_batch_size
=
eval_batch_size
)),
trainer
=
cfg
.
TrainerConfig
(
trainer
=
cfg
.
TrainerConfig
(
train_steps
=
steps_per_epoch
*
3
50
,
train_steps
=
steps_per_epoch
*
5
0
0
,
validation_steps
=
coco_val_samples
//
8
,
validation_steps
=
coco_val_samples
//
eval_batch_size
,
validation_interval
=
steps_per_epoch
,
validation_interval
=
steps_per_epoch
,
steps_per_loop
=
steps_per_epoch
,
steps_per_loop
=
steps_per_epoch
,
summary_interval
=
steps_per_epoch
,
summary_interval
=
steps_per_epoch
,
...
@@ -481,9 +505,9 @@ def maskrcnn_spinenet_coco() -> cfg.ExperimentConfig:
...
@@ -481,9 +505,9 @@ def maskrcnn_spinenet_coco() -> cfg.ExperimentConfig:
'type'
:
'stepwise'
,
'type'
:
'stepwise'
,
'stepwise'
:
{
'stepwise'
:
{
'boundaries'
:
[
'boundaries'
:
[
steps_per_epoch
*
320
,
steps_per_epoch
*
3
40
steps_per_epoch
*
475
,
steps_per_epoch
*
4
9
0
],
],
'values'
:
[
0.2
8
,
0.02
8
,
0.002
8
],
'values'
:
[
0.
3
2
,
0.0
3
2
,
0.00
3
2
],
}
}
},
},
'warmup'
:
{
'warmup'
:
{
...
...
official/vision/beta/configs/maskrcnn_test.py
View file @
f7938e6a
...
@@ -29,7 +29,7 @@ class MaskRCNNConfigTest(tf.test.TestCase, parameterized.TestCase):
...
@@ -29,7 +29,7 @@ class MaskRCNNConfigTest(tf.test.TestCase, parameterized.TestCase):
(
'fasterrcnn_resnetfpn_coco'
,),
(
'fasterrcnn_resnetfpn_coco'
,),
(
'maskrcnn_resnetfpn_coco'
,),
(
'maskrcnn_resnetfpn_coco'
,),
(
'maskrcnn_spinenet_coco'
,),
(
'maskrcnn_spinenet_coco'
,),
(
'cascadercnn_
resnetfpn
_coco'
,),
(
'cascadercnn_
spinenet
_coco'
,),
)
)
def
test_maskrcnn_configs
(
self
,
config_name
):
def
test_maskrcnn_configs
(
self
,
config_name
):
config
=
exp_factory
.
get_exp_config
(
config_name
)
config
=
exp_factory
.
get_exp_config
(
config_name
)
...
...
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