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
OpenDAS
vision
Commits
5c03d593
Commit
5c03d593
authored
Dec 11, 2019
by
TengQi Ye
Committed by
Francisco Massa
Dec 11, 2019
Browse files
Fix rpn memory leak and dataType errors. (#1657)
parent
333af7aa
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
torchvision/models/detection/_utils.py
torchvision/models/detection/_utils.py
+2
-2
torchvision/models/detection/rpn.py
torchvision/models/detection/rpn.py
+4
-2
No files found.
torchvision/models/detection/_utils.py
View file @
5c03d593
...
@@ -78,8 +78,8 @@ class BalancedPositiveNegativeSampler(object):
...
@@ -78,8 +78,8 @@ class BalancedPositiveNegativeSampler(object):
matched_idxs_per_image
,
dtype
=
torch
.
uint8
matched_idxs_per_image
,
dtype
=
torch
.
uint8
)
)
pos_idx_per_image_mask
[
pos_idx_per_image
]
=
torch
.
tensor
(
1
)
pos_idx_per_image_mask
[
pos_idx_per_image
]
=
torch
.
tensor
(
1
,
dtype
=
torch
.
uint8
)
neg_idx_per_image_mask
[
neg_idx_per_image
]
=
torch
.
tensor
(
1
)
neg_idx_per_image_mask
[
neg_idx_per_image
]
=
torch
.
tensor
(
1
,
dtype
=
torch
.
uint8
)
pos_idx
.
append
(
pos_idx_per_image_mask
)
pos_idx
.
append
(
pos_idx_per_image_mask
)
neg_idx
.
append
(
neg_idx_per_image_mask
)
neg_idx
.
append
(
neg_idx_per_image_mask
)
...
...
torchvision/models/detection/rpn.py
View file @
5c03d593
...
@@ -163,6 +163,8 @@ class AnchorGenerator(nn.Module):
...
@@ -163,6 +163,8 @@ class AnchorGenerator(nn.Module):
anchors_in_image
.
append
(
anchors_per_feature_map
)
anchors_in_image
.
append
(
anchors_per_feature_map
)
anchors
.
append
(
anchors_in_image
)
anchors
.
append
(
anchors_in_image
)
anchors
=
[
torch
.
cat
(
anchors_per_image
)
for
anchors_per_image
in
anchors
]
anchors
=
[
torch
.
cat
(
anchors_per_image
)
for
anchors_per_image
in
anchors
]
# Clear the cache in case that memory leaks.
self
.
_cache
.
clear
()
return
anchors
return
anchors
...
@@ -333,11 +335,11 @@ class RegionProposalNetwork(torch.nn.Module):
...
@@ -333,11 +335,11 @@ class RegionProposalNetwork(torch.nn.Module):
# Background (negative examples)
# Background (negative examples)
bg_indices
=
matched_idxs
==
self
.
proposal_matcher
.
BELOW_LOW_THRESHOLD
bg_indices
=
matched_idxs
==
self
.
proposal_matcher
.
BELOW_LOW_THRESHOLD
labels_per_image
[
bg_indices
]
=
torch
.
tensor
(
0
)
labels_per_image
[
bg_indices
]
=
torch
.
tensor
(
0
.0
)
# discard indices that are between thresholds
# discard indices that are between thresholds
inds_to_discard
=
matched_idxs
==
self
.
proposal_matcher
.
BETWEEN_THRESHOLDS
inds_to_discard
=
matched_idxs
==
self
.
proposal_matcher
.
BETWEEN_THRESHOLDS
labels_per_image
[
inds_to_discard
]
=
torch
.
tensor
(
-
1
)
labels_per_image
[
inds_to_discard
]
=
torch
.
tensor
(
-
1
.0
)
labels
.
append
(
labels_per_image
)
labels
.
append
(
labels_per_image
)
matched_gt_boxes
.
append
(
matched_gt_boxes_per_image
)
matched_gt_boxes
.
append
(
matched_gt_boxes_per_image
)
...
...
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