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
8e9db0f1
"docs/vscode:/vscode.git/clone" did not exist on "4f0a87b074b95802d417e0561cff45c5ffa43abc"
Commit
8e9db0f1
authored
Sep 10, 2021
by
Vishnu Banna
Browse files
loss function and init/run test
parent
a1df6e20
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1374 additions
and
0 deletions
+1374
-0
official/vision/beta/projects/yolo/losses/__init__.py
official/vision/beta/projects/yolo/losses/__init__.py
+0
-0
official/vision/beta/projects/yolo/losses/yolo_loss.py
official/vision/beta/projects/yolo/losses/yolo_loss.py
+654
-0
official/vision/beta/projects/yolo/losses/yolo_loss_test.py
official/vision/beta/projects/yolo/losses/yolo_loss_test.py
+103
-0
official/vision/beta/projects/yolo/ops/loss_utils.py
official/vision/beta/projects/yolo/ops/loss_utils.py
+617
-0
No files found.
official/vision/beta/projects/yolo/losses/__init__.py
0 → 100644
View file @
8e9db0f1
official/vision/beta/projects/yolo/losses/yolo_loss.py
0 → 100755
View file @
8e9db0f1
This diff is collapsed.
Click to expand it.
official/vision/beta/projects/yolo/losses/yolo_loss_test.py
0 → 100755
View file @
8e9db0f1
# Copyright 2021 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Lint as: python3
"""Tests for yolo heads."""
# Import libraries
from
absl.testing
import
parameterized
import
tensorflow
as
tf
from
official.vision.beta.projects.yolo.losses
import
yolo_loss
class
YoloDecoderTest
(
parameterized
.
TestCase
,
tf
.
test
.
TestCase
):
def
test_loss_init
(
self
):
"""Test creation of YOLO family models."""
def
inpdict
(
input_shape
,
dtype
=
tf
.
float32
):
inputs
=
{}
for
key
in
input_shape
:
inputs
[
key
]
=
tf
.
ones
(
input_shape
[
key
],
dtype
=
dtype
)
return
inputs
tf
.
keras
.
backend
.
set_image_data_format
(
'channels_last'
)
input_shape
=
{
'3'
:
[
1
,
52
,
52
,
255
],
'4'
:
[
1
,
26
,
26
,
255
],
'5'
:
[
1
,
13
,
13
,
255
]
}
classes
=
80
bps
=
3
masks
=
{
'3'
:
[
0
,
1
,
2
],
'4'
:
[
3
,
4
,
5
],
'5'
:
[
6
,
7
,
8
]}
anchors
=
[[
12.0
,
19.0
],
[
31.0
,
46.0
],
[
96.0
,
54.0
],
[
46.0
,
114.0
],
[
133.0
,
127.0
],
[
79.0
,
225.0
],
[
301.0
,
150.0
],
[
172.0
,
286.0
],
[
348.0
,
340.0
]]
box_type
=
{
key
:
"scaled"
for
key
in
masks
.
keys
()}
keys
=
[
'3'
,
'4'
,
'5'
]
path_strides
=
{
key
:
2
**
int
(
key
)
for
key
in
keys
}
loss
=
yolo_loss
.
YoloLoss
(
keys
,
classes
,
anchors
,
masks
=
masks
,
path_strides
=
path_strides
,
truth_thresholds
=
{
key
:
1.0
for
key
in
keys
},
ignore_thresholds
=
{
key
:
0.7
for
key
in
keys
},
loss_types
=
{
key
:
"ciou"
for
key
in
keys
},
iou_normalizers
=
{
key
:
0.05
for
key
in
keys
},
cls_normalizers
=
{
key
:
0.5
for
key
in
keys
},
obj_normalizers
=
{
key
:
1.0
for
key
in
keys
},
objectness_smooths
=
{
key
:
1.0
for
key
in
keys
},
box_types
=
{
key
:
"scaled"
for
key
in
keys
},
scale_xys
=
{
key
:
2.0
for
key
in
keys
},
max_deltas
=
{
key
:
30.0
for
key
in
keys
},
label_smoothing
=
0.0
,
use_scaled_loss
=
True
,
update_on_repeat
=
True
)
count
=
inpdict
({
'3'
:
[
1
,
52
,
52
,
3
,
1
],
'4'
:
[
1
,
26
,
26
,
3
,
1
],
'5'
:
[
1
,
13
,
13
,
3
,
1
]
})
ind
=
inpdict
({
'3'
:
[
1
,
300
,
3
],
'4'
:
[
1
,
300
,
3
],
'5'
:
[
1
,
300
,
3
]
},
tf
.
int32
)
truths
=
inpdict
({
'3'
:
[
1
,
300
,
8
],
'4'
:
[
1
,
300
,
8
],
'5'
:
[
1
,
300
,
8
]
})
boxes
=
tf
.
ones
([
1
,
300
,
4
],
dtype
=
tf
.
float32
)
classes
=
tf
.
ones
([
1
,
300
],
dtype
=
tf
.
float32
)
gt
=
{
"true_conf"
:
count
,
"inds"
:
ind
,
"upds"
:
truths
,
"bbox"
:
boxes
,
"classes"
:
classes
}
loss_val
,
metric_loss
,
metric_dict
=
loss
(
gt
,
inpdict
(
input_shape
))
if
__name__
==
'__main__'
:
tf
.
test
.
main
()
official/vision/beta/projects/yolo/ops/loss_utils.py
0 → 100755
View file @
8e9db0f1
This diff is collapsed.
Click to expand it.
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