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
9778d267
Unverified
Commit
9778d267
authored
Apr 16, 2021
by
Prabhat Roy
Committed by
GitHub
Apr 16, 2021
Browse files
Fixed floor_divide deprecation warnings seen in pytest output (#3672)
parent
3926c905
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
9 deletions
+12
-9
test/test_datasets_samplers.py
test/test_datasets_samplers.py
+3
-3
torchvision/datasets/celeba.py
torchvision/datasets/celeba.py
+2
-1
torchvision/models/detection/retinanet.py
torchvision/models/detection/retinanet.py
+1
-1
torchvision/models/detection/roi_heads.py
torchvision/models/detection/roi_heads.py
+1
-1
torchvision/transforms/functional_tensor.py
torchvision/transforms/functional_tensor.py
+5
-3
No files found.
test/test_datasets_samplers.py
View file @
9778d267
...
@@ -45,7 +45,7 @@ class Tester(unittest.TestCase):
...
@@ -45,7 +45,7 @@ class Tester(unittest.TestCase):
sampler
=
RandomClipSampler
(
video_clips
,
3
)
sampler
=
RandomClipSampler
(
video_clips
,
3
)
self
.
assertEqual
(
len
(
sampler
),
3
*
3
)
self
.
assertEqual
(
len
(
sampler
),
3
*
3
)
indices
=
torch
.
tensor
(
list
(
iter
(
sampler
)))
indices
=
torch
.
tensor
(
list
(
iter
(
sampler
)))
videos
=
indices
//
5
videos
=
torch
.
div
(
indices
,
5
,
rounding_mode
=
'floor'
)
v_idxs
,
count
=
torch
.
unique
(
videos
,
return_counts
=
True
)
v_idxs
,
count
=
torch
.
unique
(
videos
,
return_counts
=
True
)
self
.
assertTrue
(
v_idxs
.
equal
(
torch
.
tensor
([
0
,
1
,
2
])))
self
.
assertTrue
(
v_idxs
.
equal
(
torch
.
tensor
([
0
,
1
,
2
])))
self
.
assertTrue
(
count
.
equal
(
torch
.
tensor
([
3
,
3
,
3
])))
self
.
assertTrue
(
count
.
equal
(
torch
.
tensor
([
3
,
3
,
3
])))
...
@@ -62,7 +62,7 @@ class Tester(unittest.TestCase):
...
@@ -62,7 +62,7 @@ class Tester(unittest.TestCase):
indices
.
remove
(
0
)
indices
.
remove
(
0
)
indices
.
remove
(
1
)
indices
.
remove
(
1
)
indices
=
torch
.
tensor
(
indices
)
-
2
indices
=
torch
.
tensor
(
indices
)
-
2
videos
=
indices
//
5
videos
=
torch
.
div
(
indices
,
5
,
rounding_mode
=
'floor'
)
v_idxs
,
count
=
torch
.
unique
(
videos
,
return_counts
=
True
)
v_idxs
,
count
=
torch
.
unique
(
videos
,
return_counts
=
True
)
self
.
assertTrue
(
v_idxs
.
equal
(
torch
.
tensor
([
0
,
1
])))
self
.
assertTrue
(
v_idxs
.
equal
(
torch
.
tensor
([
0
,
1
])))
self
.
assertTrue
(
count
.
equal
(
torch
.
tensor
([
3
,
3
])))
self
.
assertTrue
(
count
.
equal
(
torch
.
tensor
([
3
,
3
])))
...
@@ -73,7 +73,7 @@ class Tester(unittest.TestCase):
...
@@ -73,7 +73,7 @@ class Tester(unittest.TestCase):
sampler
=
UniformClipSampler
(
video_clips
,
3
)
sampler
=
UniformClipSampler
(
video_clips
,
3
)
self
.
assertEqual
(
len
(
sampler
),
3
*
3
)
self
.
assertEqual
(
len
(
sampler
),
3
*
3
)
indices
=
torch
.
tensor
(
list
(
iter
(
sampler
)))
indices
=
torch
.
tensor
(
list
(
iter
(
sampler
)))
videos
=
indices
//
5
videos
=
torch
.
div
(
indices
,
5
,
rounding_mode
=
'floor'
)
v_idxs
,
count
=
torch
.
unique
(
videos
,
return_counts
=
True
)
v_idxs
,
count
=
torch
.
unique
(
videos
,
return_counts
=
True
)
self
.
assertTrue
(
v_idxs
.
equal
(
torch
.
tensor
([
0
,
1
,
2
])))
self
.
assertTrue
(
v_idxs
.
equal
(
torch
.
tensor
([
0
,
1
,
2
])))
self
.
assertTrue
(
count
.
equal
(
torch
.
tensor
([
3
,
3
,
3
])))
self
.
assertTrue
(
count
.
equal
(
torch
.
tensor
([
3
,
3
,
3
])))
...
...
torchvision/datasets/celeba.py
View file @
9778d267
...
@@ -104,7 +104,8 @@ class CelebA(VisionDataset):
...
@@ -104,7 +104,8 @@ class CelebA(VisionDataset):
self
.
bbox
=
bbox
.
data
[
mask
]
self
.
bbox
=
bbox
.
data
[
mask
]
self
.
landmarks_align
=
landmarks_align
.
data
[
mask
]
self
.
landmarks_align
=
landmarks_align
.
data
[
mask
]
self
.
attr
=
attr
.
data
[
mask
]
self
.
attr
=
attr
.
data
[
mask
]
self
.
attr
=
(
self
.
attr
+
1
)
//
2
# map from {-1, 1} to {0, 1}
# map from {-1, 1} to {0, 1}
self
.
attr
=
torch
.
div
(
self
.
attr
+
1
,
2
,
rounding_mode
=
'floor'
)
self
.
attr_names
=
attr
.
header
self
.
attr_names
=
attr
.
header
def
_load_csv
(
def
_load_csv
(
...
...
torchvision/models/detection/retinanet.py
View file @
9778d267
...
@@ -428,7 +428,7 @@ class RetinaNet(nn.Module):
...
@@ -428,7 +428,7 @@ class RetinaNet(nn.Module):
scores_per_level
,
idxs
=
scores_per_level
.
topk
(
num_topk
)
scores_per_level
,
idxs
=
scores_per_level
.
topk
(
num_topk
)
topk_idxs
=
topk_idxs
[
idxs
]
topk_idxs
=
topk_idxs
[
idxs
]
anchor_idxs
=
topk_idxs
//
num_classes
anchor_idxs
=
torch
.
div
(
topk_idxs
,
num_classes
,
rounding_mode
=
'floor'
)
labels_per_level
=
topk_idxs
%
num_classes
labels_per_level
=
topk_idxs
%
num_classes
boxes_per_level
=
self
.
box_coder
.
decode_single
(
box_regression_per_level
[
anchor_idxs
],
boxes_per_level
=
self
.
box_coder
.
decode_single
(
box_regression_per_level
[
anchor_idxs
],
...
...
torchvision/models/detection/roi_heads.py
View file @
9778d267
...
@@ -266,7 +266,7 @@ def heatmaps_to_keypoints(maps, rois):
...
@@ -266,7 +266,7 @@ def heatmaps_to_keypoints(maps, rois):
pos
=
roi_map
.
reshape
(
num_keypoints
,
-
1
).
argmax
(
dim
=
1
)
pos
=
roi_map
.
reshape
(
num_keypoints
,
-
1
).
argmax
(
dim
=
1
)
x_int
=
pos
%
w
x_int
=
pos
%
w
y_int
=
(
pos
-
x_int
)
//
w
y_int
=
torch
.
div
(
pos
-
x_int
,
w
,
rounding_mode
=
'floor'
)
# assert (roi_map_probs[k, y_int, x_int] ==
# assert (roi_map_probs[k, y_int, x_int] ==
# roi_map_probs[k, :, :].max())
# roi_map_probs[k, :, :].max())
x
=
(
x_int
.
float
()
+
0.5
)
*
width_correction
x
=
(
x_int
.
float
()
+
0.5
)
*
width_correction
...
...
torchvision/transforms/functional_tensor.py
View file @
9778d267
...
@@ -97,7 +97,7 @@ def convert_image_dtype(image: torch.Tensor, dtype: torch.dtype = torch.float) -
...
@@ -97,7 +97,7 @@ def convert_image_dtype(image: torch.Tensor, dtype: torch.dtype = torch.float) -
# factor should be forced to int for torch jit script
# factor should be forced to int for torch jit script
# otherwise factor is a float and image // factor can produce different results
# otherwise factor is a float and image // factor can produce different results
factor
=
int
((
input_max
+
1
)
//
(
output_max
+
1
))
factor
=
int
((
input_max
+
1
)
//
(
output_max
+
1
))
image
=
image
//
factor
image
=
torch
.
div
(
image
,
factor
,
rounding_mode
=
'floor'
)
return
image
.
to
(
dtype
)
return
image
.
to
(
dtype
)
else
:
else
:
# factor should be forced to int for torch jit script
# factor should be forced to int for torch jit script
...
@@ -908,11 +908,13 @@ def _scale_channel(img_chan):
...
@@ -908,11 +908,13 @@ def _scale_channel(img_chan):
hist
=
torch
.
bincount
(
img_chan
.
view
(
-
1
),
minlength
=
256
)
hist
=
torch
.
bincount
(
img_chan
.
view
(
-
1
),
minlength
=
256
)
nonzero_hist
=
hist
[
hist
!=
0
]
nonzero_hist
=
hist
[
hist
!=
0
]
step
=
nonzero_hist
[:
-
1
].
sum
()
//
255
step
=
torch
.
div
(
nonzero_hist
[:
-
1
].
sum
()
,
255
,
rounding_mode
=
'floor'
)
if
step
==
0
:
if
step
==
0
:
return
img_chan
return
img_chan
lut
=
(
torch
.
cumsum
(
hist
,
0
)
+
(
step
//
2
))
//
step
lut
=
torch
.
div
(
torch
.
cumsum
(
hist
,
0
)
+
torch
.
div
(
step
,
2
,
rounding_mode
=
'floor'
),
step
,
rounding_mode
=
'floor'
)
lut
=
torch
.
nn
.
functional
.
pad
(
lut
,
[
1
,
0
])[:
-
1
].
clamp
(
0
,
255
)
lut
=
torch
.
nn
.
functional
.
pad
(
lut
,
[
1
,
0
])[:
-
1
].
clamp
(
0
,
255
)
return
lut
[
img_chan
.
to
(
torch
.
int64
)].
to
(
torch
.
uint8
)
return
lut
[
img_chan
.
to
(
torch
.
int64
)].
to
(
torch
.
uint8
)
...
...
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