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
c5826f37
Commit
c5826f37
authored
Sep 06, 2021
by
Vishnu Banna
Browse files
addressing ocmments
parent
420594a8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
23 deletions
+9
-23
official/vision/beta/projects/yolo/modeling/backbones/darknet.py
...l/vision/beta/projects/yolo/modeling/backbones/darknet.py
+1
-2
official/vision/beta/projects/yolo/modeling/factory.py
official/vision/beta/projects/yolo/modeling/factory.py
+3
-9
official/vision/beta/projects/yolo/modeling/layers/detection_generator.py
...beta/projects/yolo/modeling/layers/detection_generator.py
+3
-7
official/vision/beta/projects/yolo/modeling/layers/detection_generator_test.py
...projects/yolo/modeling/layers/detection_generator_test.py
+2
-5
No files found.
official/vision/beta/projects/yolo/modeling/backbones/darknet.py
View file @
c5826f37
...
@@ -665,8 +665,7 @@ def build_darknet(
...
@@ -665,8 +665,7 @@ def build_darknet(
l2_regularizer
:
tf
.
keras
.
regularizers
.
Regularizer
=
None
)
->
tf
.
keras
.
Model
:
l2_regularizer
:
tf
.
keras
.
regularizers
.
Regularizer
=
None
)
->
tf
.
keras
.
Model
:
"""Builds darknet."""
"""Builds darknet."""
backbone_cfg
=
backbone_config
.
backbone
.
get
()
backbone_cfg
=
backbone_config
.
get
()
model
=
Darknet
(
model
=
Darknet
(
model_id
=
backbone_cfg
.
model_id
,
model_id
=
backbone_cfg
.
model_id
,
min_level
=
backbone_cfg
.
min_level
,
min_level
=
backbone_cfg
.
min_level
,
...
...
official/vision/beta/projects/yolo/modeling/factory.py
View file @
c5826f37
...
@@ -65,7 +65,6 @@ def build_yolo_decoder(input_specs, model_config: yolo.Yolo, l2_regularization):
...
@@ -65,7 +65,6 @@ def build_yolo_decoder(input_specs, model_config: yolo.Yolo, l2_regularization):
kernel_regularizer
=
l2_regularization
)
kernel_regularizer
=
l2_regularization
)
base_model
.
update
(
base_dict
)
base_model
.
update
(
base_dict
)
print
(
base_model
)
model
=
YoloDecoder
(
input_specs
,
**
base_model
)
model
=
YoloDecoder
(
input_specs
,
**
base_model
)
...
@@ -74,14 +73,14 @@ def build_yolo_decoder(input_specs, model_config: yolo.Yolo, l2_regularization):
...
@@ -74,14 +73,14 @@ def build_yolo_decoder(input_specs, model_config: yolo.Yolo, l2_regularization):
def
build_yolo_filter
(
model_config
:
yolo
.
Yolo
,
decoder
:
YoloDecoder
,
masks
,
def
build_yolo_filter
(
model_config
:
yolo
.
Yolo
,
decoder
:
YoloDecoder
,
masks
,
xy_scales
,
path_scales
):
xy_scales
,
path_scales
):
def
_build
(
values
):
def
_build
(
values
):
print
(
values
)
"""Used to make model cfg shorter when different FPN lvls require
different hyper paramters while others do not. The term all will
blanket set the same hyper paramter for all FPN levels."""
if
"all"
in
values
and
values
[
"all"
]
is
not
None
:
if
"all"
in
values
and
values
[
"all"
]
is
not
None
:
for
key
in
values
:
for
key
in
values
:
if
key
!=
'all'
:
if
key
!=
'all'
:
values
[
key
]
=
values
[
"all"
]
values
[
key
]
=
values
[
"all"
]
print
(
values
)
return
values
return
values
model
=
YoloLayer
(
model
=
YoloLayer
(
...
@@ -125,12 +124,7 @@ def build_yolo_head(input_specs, model_config: yolo.Yolo, l2_regularization):
...
@@ -125,12 +124,7 @@ def build_yolo_head(input_specs, model_config: yolo.Yolo, l2_regularization):
def
build_yolo
(
input_specs
,
model_config
,
l2_regularization
,
masks
,
xy_scales
,
def
build_yolo
(
input_specs
,
model_config
,
l2_regularization
,
masks
,
xy_scales
,
path_scales
):
path_scales
):
print
(
model_config
.
as_dict
())
print
(
input_specs
)
print
(
l2_regularization
)
# backbone = factory.build_backbone(input_specs, model_config,
# l2_regularization)
backbone
=
build_darknet
(
input_specs
,
model_config
,
backbone
=
build_darknet
(
input_specs
,
model_config
,
l2_regularization
)
l2_regularization
)
decoder
=
build_yolo_decoder
(
backbone
.
output_specs
,
model_config
,
decoder
=
build_yolo_decoder
(
backbone
.
output_specs
,
model_config
,
...
...
official/vision/beta/projects/yolo/modeling/layers/detection_generator.py
View file @
c5826f37
"""Contains common building blocks for yolo neural networ
k
s."""
"""Contains common building blocks for yolo neural networ
tf.kera
s."""
import
tensorflow
as
tf
import
tensorflow
as
tf
import
tensorflow.keras
as
ks
import
tensorflow.keras.backend
as
K
import
tensorflow.keras.backend
as
K
from
official.vision.beta.projects.yolo.ops
import
box_ops
from
official.vision.beta.projects.yolo.ops
import
box_ops
@
k
s
.
utils
.
register_keras_serializable
(
package
=
'yolo'
)
@
tf
.
kera
s
.
utils
.
register_keras_serializable
(
package
=
'yolo'
)
class
YoloLayer
(
k
s
.
Model
):
class
YoloLayer
(
tf
.
kera
s
.
Model
):
def
__init__
(
self
,
def
__init__
(
self
,
masks
,
masks
,
...
@@ -134,9 +133,6 @@ class YoloLayer(ks.Model):
...
@@ -134,9 +133,6 @@ class YoloLayer(ks.Model):
self
.
_nms_type
=
self
.
_nms_types
[
nms_type
]
self
.
_nms_type
=
self
.
_nms_types
[
nms_type
]
if
self
.
_nms_type
>=
2
and
self
.
_nms_type
<=
5
:
self
.
_nms
=
nms_ops
.
TiledNMS
(
iou_type
=
nms_type
)
self
.
_scale_xy
=
scale_xy
or
{
key
:
1.0
for
key
,
_
in
masks
.
items
()}
self
.
_scale_xy
=
scale_xy
or
{
key
:
1.0
for
key
,
_
in
masks
.
items
()}
self
.
_generator
=
{}
self
.
_generator
=
{}
...
...
official/vision/beta/projects/yolo/modeling/layers/detection_generator_test.py
View file @
c5826f37
...
@@ -15,17 +15,14 @@
...
@@ -15,17 +15,14 @@
# ==============================================================================
# ==============================================================================
"""Tests for yolo."""
"""Tests for yolo."""
# Import libraries
from
absl.testing
import
parameterized
from
absl.testing
import
parameterized
import
numpy
as
np
import
numpy
as
np
import
tensorflow
as
tf
import
tensorflow
as
tf
from
tensorflow.python.distribute
import
combinations
from
tensorflow.python.distribute
import
combinations
from
tensorflow.python.distribute
import
strategy_combinations
from
tensorflow.python.distribute
import
strategy_combinations
# from official.vision.beta.projects.yolo.modeling.backbones import darknet
from
official.vision.beta.projects.yolo.modeling.layers
import
detection_generator
as
dg
from
official.vision.beta.projects.yolo.modeling.layers
import
detection_generator
as
dg
class
YoloDecoderTest
(
parameterized
.
TestCase
,
tf
.
test
.
TestCase
):
class
YoloDecoderTest
(
parameterized
.
TestCase
,
tf
.
test
.
TestCase
):
@
parameterized
.
parameters
(
@
parameterized
.
parameters
(
...
@@ -61,6 +58,6 @@ class YoloDecoderTest(parameterized.TestCase, tf.test.TestCase):
...
@@ -61,6 +58,6 @@ class YoloDecoderTest(parameterized.TestCase, tf.test.TestCase):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
from
yolo.utils.run_utils
import
prep_gpu
#
from yolo.utils.run_utils import prep_gpu
prep_gpu
()
#
prep_gpu()
tf
.
test
.
main
()
tf
.
test
.
main
()
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