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
ff81e2b1
Unverified
Commit
ff81e2b1
authored
Mar 13, 2020
by
Ailing
Committed by
GitHub
Mar 13, 2020
Browse files
Add device to torch.tensor. (#1979)
parent
4d77d3fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
torchvision/models/detection/_utils.py
torchvision/models/detection/_utils.py
+4
-4
No files found.
torchvision/models/detection/_utils.py
View file @
ff81e2b1
...
@@ -220,10 +220,10 @@ class BoxCoder(object):
...
@@ -220,10 +220,10 @@ class BoxCoder(object):
pred_w
=
torch
.
exp
(
dw
)
*
widths
[:,
None
]
pred_w
=
torch
.
exp
(
dw
)
*
widths
[:,
None
]
pred_h
=
torch
.
exp
(
dh
)
*
heights
[:,
None
]
pred_h
=
torch
.
exp
(
dh
)
*
heights
[:,
None
]
pred_boxes1
=
pred_ctr_x
-
torch
.
tensor
(
0.5
,
dtype
=
pred_ctr_x
.
dtype
)
*
pred_w
pred_boxes1
=
pred_ctr_x
-
torch
.
tensor
(
0.5
,
dtype
=
pred_ctr_x
.
dtype
,
device
=
pred_w
.
device
)
*
pred_w
pred_boxes2
=
pred_ctr_y
-
torch
.
tensor
(
0.5
,
dtype
=
pred_ctr_y
.
dtype
)
*
pred_h
pred_boxes2
=
pred_ctr_y
-
torch
.
tensor
(
0.5
,
dtype
=
pred_ctr_y
.
dtype
,
device
=
pred_h
.
device
)
*
pred_h
pred_boxes3
=
pred_ctr_x
+
torch
.
tensor
(
0.5
,
dtype
=
pred_ctr_x
.
dtype
)
*
pred_w
pred_boxes3
=
pred_ctr_x
+
torch
.
tensor
(
0.5
,
dtype
=
pred_ctr_x
.
dtype
,
device
=
pred_w
.
device
)
*
pred_w
pred_boxes4
=
pred_ctr_y
+
torch
.
tensor
(
0.5
,
dtype
=
pred_ctr_y
.
dtype
)
*
pred_h
pred_boxes4
=
pred_ctr_y
+
torch
.
tensor
(
0.5
,
dtype
=
pred_ctr_y
.
dtype
,
device
=
pred_h
.
device
)
*
pred_h
pred_boxes
=
torch
.
stack
((
pred_boxes1
,
pred_boxes2
,
pred_boxes3
,
pred_boxes4
),
dim
=
2
).
flatten
(
1
)
pred_boxes
=
torch
.
stack
((
pred_boxes1
,
pred_boxes2
,
pred_boxes3
,
pred_boxes4
),
dim
=
2
).
flatten
(
1
)
return
pred_boxes
return
pred_boxes
...
...
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