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
f0899f18
Commit
f0899f18
authored
Feb 28, 2019
by
aquariusjay
Committed by
Yukun Zhu
Feb 28, 2019
Browse files
Update the codes due to recent change in DeepLab. (#6287)
parent
4b566d4e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
20 deletions
+41
-20
research/feelvos/common.py
research/feelvos/common.py
+24
-0
research/feelvos/model.py
research/feelvos/model.py
+4
-3
research/feelvos/train.py
research/feelvos/train.py
+2
-2
research/feelvos/utils/embedding_utils.py
research/feelvos/utils/embedding_utils.py
+9
-13
research/feelvos/vis_video.py
research/feelvos/vis_video.py
+2
-2
No files found.
research/feelvos/common.py
View file @
f0899f18
...
@@ -137,3 +137,27 @@ class VideoModelOptions(common.ModelOptions):
...
@@ -137,3 +137,27 @@ class VideoModelOptions(common.ModelOptions):
self
.
classification_loss
=
FLAGS
.
classification_loss
self
.
classification_loss
=
FLAGS
.
classification_loss
return
self
return
self
def
parse_decoder_output_stride
():
"""Parses decoder output stride.
FEELVOS assumes decoder_output_stride = 4. Thus, this function is created for
this particular purpose.
Returns:
An integer specifying the decoder_output_stride.
Raises:
ValueError: If decoder_output_stride is None or contains more than one
element.
"""
if
FLAGS
.
decoder_output_stride
:
decoder_output_stride
=
[
int
(
x
)
for
x
in
FLAGS
.
decoder_output_stride
]
if
len
(
decoder_output_stride
)
!=
1
:
raise
ValueError
(
'Expect decoder output stride has only one element.'
)
decoder_output_stride
=
decoder_output_stride
[
0
]
else
:
raise
ValueError
(
'Expect flag decoder output stride not to be None.'
)
return
decoder_output_stride
research/feelvos/model.py
View file @
f0899f18
...
@@ -359,9 +359,10 @@ def multi_scale_logits_with_nearest_neighbor_matching(
...
@@ -359,9 +359,10 @@ def multi_scale_logits_with_nearest_neighbor_matching(
if
model_options
.
crop_size
else
tf
.
shape
(
images
)[
2
])
if
model_options
.
crop_size
else
tf
.
shape
(
images
)[
2
])
# Compute the height, width for the output logits.
# Compute the height, width for the output logits.
logits_output_stride
=
(
if
model_options
.
decoder_output_stride
:
model_options
.
decoder_output_stride
or
model_options
.
output_stride
)
logits_output_stride
=
min
(
model_options
.
decoder_output_stride
)
else
:
logits_output_stride
=
model_options
.
output_stride
logits_height
=
scale_dimension
(
logits_height
=
scale_dimension
(
crop_height
,
crop_height
,
max
(
1.0
,
max
(
image_pyramid
))
/
logits_output_stride
)
max
(
1.0
,
max
(
image_pyramid
))
/
logits_output_stride
)
...
...
research/feelvos/train.py
View file @
f0899f18
...
@@ -266,7 +266,7 @@ def _build_deeplab(inputs_queue_or_samples, outputs_to_num_classes,
...
@@ -266,7 +266,7 @@ def _build_deeplab(inputs_queue_or_samples, outputs_to_num_classes,
preceding_frame_label
[
n
,
tf
.
newaxis
],
preceding_frame_label
[
n
,
tf
.
newaxis
],
samples
[
common
.
LABEL
][
n
*
FLAGS
.
train_num_frames_per_video
,
samples
[
common
.
LABEL
][
n
*
FLAGS
.
train_num_frames_per_video
,
tf
.
newaxis
],
tf
.
newaxis
],
FLAGS
.
decoder_output_stride
,
common
.
parse_
decoder_output_stride
()
,
reduce_labels
=
True
)
reduce_labels
=
True
)
init_softmax_n
=
tf
.
squeeze
(
init_softmax_n
,
axis
=
0
)
init_softmax_n
=
tf
.
squeeze
(
init_softmax_n
,
axis
=
0
)
init_softmax
.
append
(
init_softmax_n
)
init_softmax
.
append
(
init_softmax_n
)
...
@@ -610,7 +610,7 @@ def _get_dataset_and_samples(config, train_crop_size, dataset_name,
...
@@ -610,7 +610,7 @@ def _get_dataset_and_samples(config, train_crop_size, dataset_name,
is_training
=
True
,
is_training
=
True
,
model_variant
=
FLAGS
.
model_variant
,
model_variant
=
FLAGS
.
model_variant
,
batch_capacity_factor
=
FLAGS
.
batch_capacity_factor
,
batch_capacity_factor
=
FLAGS
.
batch_capacity_factor
,
decoder_output_stride
=
FLAGS
.
decoder_output_stride
,
decoder_output_stride
=
common
.
parse_
decoder_output_stride
()
,
first_frame_finetuning
=
first_frame_finetuning
,
first_frame_finetuning
=
first_frame_finetuning
,
sample_only_first_frame_for_finetuning
=
sample_only_first_frame_for_finetuning
=
FLAGS
.
sample_only_first_frame_for_finetuning
,
FLAGS
.
sample_only_first_frame_for_finetuning
,
...
...
research/feelvos/utils/embedding_utils.py
View file @
f0899f18
...
@@ -482,20 +482,17 @@ def get_embeddings(images, model_options, embedding_dimension):
...
@@ -482,20 +482,17 @@ def get_embeddings(images, model_options, embedding_dimension):
is_training
=
False
)
is_training
=
False
)
if
model_options
.
decoder_output_stride
is
not
None
:
if
model_options
.
decoder_output_stride
is
not
None
:
decoder_output_stride
=
min
(
model_options
.
decoder_output_stride
)
if
model_options
.
crop_size
is
None
:
if
model_options
.
crop_size
is
None
:
height
=
tf
.
shape
(
images
)[
1
]
height
=
tf
.
shape
(
images
)[
1
]
width
=
tf
.
shape
(
images
)[
2
]
width
=
tf
.
shape
(
images
)[
2
]
else
:
else
:
height
,
width
=
model_options
.
crop_size
height
,
width
=
model_options
.
crop_size
decoder_height
=
model
.
scale_dimension
(
height
,
1.0
/
model_options
.
decoder_output_stride
)
decoder_width
=
model
.
scale_dimension
(
width
,
1.0
/
model_options
.
decoder_output_stride
)
features
=
model
.
refine_by_decoder
(
features
=
model
.
refine_by_decoder
(
features
,
features
,
end_points
,
end_points
,
decoder_height
=
decoder_height
,
crop_size
=
[
height
,
width
]
,
decoder_
width
=
decoder_width
,
decoder_
output_stride
=
[
decoder_output_stride
]
,
decoder_use_separable_conv
=
model_options
.
decoder_use_separable_conv
,
decoder_use_separable_conv
=
model_options
.
decoder_use_separable_conv
,
model_variant
=
model_options
.
model_variant
,
model_variant
=
model_options
.
model_variant
,
is_training
=
False
)
is_training
=
False
)
...
@@ -596,21 +593,20 @@ def get_logits_with_matching(images,
...
@@ -596,21 +593,20 @@ def get_logits_with_matching(images,
is_training
=
is_training
,
is_training
=
is_training
,
fine_tune_batch_norm
=
fine_tune_batch_norm
)
fine_tune_batch_norm
=
fine_tune_batch_norm
)
if
model_options
.
decoder_output_stride
is
not
None
:
if
model_options
.
decoder_output_stride
:
decoder_output_stride
=
min
(
model_options
.
decoder_output_stride
)
if
model_options
.
crop_size
is
None
:
if
model_options
.
crop_size
is
None
:
height
=
tf
.
shape
(
images
)[
1
]
height
=
tf
.
shape
(
images
)[
1
]
width
=
tf
.
shape
(
images
)[
2
]
width
=
tf
.
shape
(
images
)[
2
]
else
:
else
:
height
,
width
=
model_options
.
crop_size
height
,
width
=
model_options
.
crop_size
decoder_height
=
model
.
scale_dimension
(
decoder_height
=
model
.
scale_dimension
(
height
,
1.0
/
decoder_output_stride
)
height
,
1.0
/
model_options
.
decoder_output_stride
)
decoder_width
=
model
.
scale_dimension
(
width
,
1.0
/
decoder_output_stride
)
decoder_width
=
model
.
scale_dimension
(
width
,
1.0
/
model_options
.
decoder_output_stride
)
features
=
model
.
refine_by_decoder
(
features
=
model
.
refine_by_decoder
(
features
,
features
,
end_points
,
end_points
,
decoder_height
=
decoder_height
,
crop_size
=
[
height
,
width
]
,
decoder_
width
=
decoder_width
,
decoder_
output_stride
=
[
decoder_output_stride
]
,
decoder_use_separable_conv
=
model_options
.
decoder_use_separable_conv
,
decoder_use_separable_conv
=
model_options
.
decoder_use_separable_conv
,
model_variant
=
model_options
.
model_variant
,
model_variant
=
model_options
.
model_variant
,
weight_decay
=
weight_decay
,
weight_decay
=
weight_decay
,
...
...
research/feelvos/vis_video.py
View file @
f0899f18
...
@@ -222,7 +222,7 @@ def create_predictions(samples, reference_labels, first_frame_img,
...
@@ -222,7 +222,7 @@ def create_predictions(samples, reference_labels, first_frame_img,
init_labels
=
tf
.
squeeze
(
reference_labels
,
axis
=-
1
)
init_labels
=
tf
.
squeeze
(
reference_labels
,
axis
=-
1
)
init_softmax
=
embedding_utils
.
create_initial_softmax_from_labels
(
init_softmax
=
embedding_utils
.
create_initial_softmax_from_labels
(
reference_labels
,
reference_labels
,
FLAGS
.
decoder_output_stride
,
reference_labels
,
reference_labels
,
common
.
parse_
decoder_output_stride
()
,
reduce_labels
=
False
)
reduce_labels
=
False
)
if
FLAGS
.
save_embeddings
:
if
FLAGS
.
save_embeddings
:
decoder_height
=
tf
.
shape
(
init_softmax
)[
1
]
decoder_height
=
tf
.
shape
(
init_softmax
)[
1
]
...
@@ -298,7 +298,7 @@ def create_predictions_fast(samples, reference_labels, first_frame_img,
...
@@ -298,7 +298,7 @@ def create_predictions_fast(samples, reference_labels, first_frame_img,
first_frame_img
[
tf
.
newaxis
],
model_options
,
FLAGS
.
embedding_dimension
)
first_frame_img
[
tf
.
newaxis
],
model_options
,
FLAGS
.
embedding_dimension
)
init_labels
=
tf
.
squeeze
(
reference_labels
,
axis
=-
1
)
init_labels
=
tf
.
squeeze
(
reference_labels
,
axis
=-
1
)
init_softmax
=
embedding_utils
.
create_initial_softmax_from_labels
(
init_softmax
=
embedding_utils
.
create_initial_softmax_from_labels
(
reference_labels
,
reference_labels
,
FLAGS
.
decoder_output_stride
,
reference_labels
,
reference_labels
,
common
.
parse_
decoder_output_stride
()
,
reduce_labels
=
False
)
reduce_labels
=
False
)
init
=
(
init_labels
,
init_softmax
,
first_frame_embeddings
)
init
=
(
init_labels
,
init_softmax
,
first_frame_embeddings
)
...
...
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