Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Swin-Transformer-Object-Detection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wanggh
Swin-Transformer-Object-Detection
Commits
ac8d34e7
Commit
ac8d34e7
authored
5 years ago
by
Kai Chen
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of github.com:open-mmlab/mmdetection
parents
b88561db
a054aef4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mmdet/core/anchor/anchor_target.py
+0
-10
0 additions, 10 deletions
mmdet/core/anchor/anchor_target.py
mmdet/core/loss/losses.py
+12
-0
12 additions, 0 deletions
mmdet/core/loss/losses.py
with
12 additions
and
10 deletions
mmdet/core/anchor/anchor_target.py
+
0
−
10
View file @
ac8d34e7
...
...
@@ -159,16 +159,6 @@ def anchor_target_single(flat_anchors,
neg_inds
)
def
expand_binary_labels
(
labels
,
label_weights
,
label_channels
):
bin_labels
=
labels
.
new_full
((
labels
.
size
(
0
),
label_channels
),
0
)
inds
=
torch
.
nonzero
(
labels
>=
1
).
squeeze
()
if
inds
.
numel
()
>
0
:
bin_labels
[
inds
,
labels
[
inds
]
-
1
]
=
1
bin_label_weights
=
label_weights
.
view
(
-
1
,
1
).
expand
(
label_weights
.
size
(
0
),
label_channels
)
return
bin_labels
,
bin_label_weights
def
anchor_inside_flags
(
flat_anchors
,
valid_flags
,
img_shape
,
allowed_border
=
0
):
img_h
,
img_w
=
img_shape
[:
2
]
...
...
This diff is collapsed.
Click to expand it.
mmdet/core/loss/losses.py
+
12
−
0
View file @
ac8d34e7
...
...
@@ -23,6 +23,8 @@ def weighted_cross_entropy(pred, label, weight, avg_factor=None, reduce=True):
def
weighted_binary_cross_entropy
(
pred
,
label
,
weight
,
avg_factor
=
None
):
if
pred
.
dim
()
!=
label
.
dim
():
label
,
weight
=
_expand_binary_labels
(
label
,
weight
,
pred
.
size
(
-
1
))
if
avg_factor
is
None
:
avg_factor
=
max
(
torch
.
sum
(
weight
>
0
).
float
().
item
(),
1.
)
return
F
.
binary_cross_entropy_with_logits
(
...
...
@@ -115,3 +117,13 @@ def accuracy(pred, target, topk=1):
correct_k
=
correct
[:
k
].
view
(
-
1
).
float
().
sum
(
0
,
keepdim
=
True
)
res
.
append
(
correct_k
.
mul_
(
100.0
/
pred
.
size
(
0
)))
return
res
[
0
]
if
return_single
else
res
def
_expand_binary_labels
(
labels
,
label_weights
,
label_channels
):
bin_labels
=
labels
.
new_full
((
labels
.
size
(
0
),
label_channels
),
0
)
inds
=
torch
.
nonzero
(
labels
>=
1
).
squeeze
()
if
inds
.
numel
()
>
0
:
bin_labels
[
inds
,
labels
[
inds
]
-
1
]
=
1
bin_label_weights
=
label_weights
.
view
(
-
1
,
1
).
expand
(
label_weights
.
size
(
0
),
label_channels
)
return
bin_labels
,
bin_label_weights
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment