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
b06ea39d
Unverified
Commit
b06ea39d
authored
May 11, 2023
by
Christoph Reich
Committed by
GitHub
May 11, 2023
Browse files
Assert RAFT input resolution is 128 x 128 or higher (#7339)
Co-authored-by:
Nicolas Hug
<
nicolashug@meta.com
>
parent
62c22317
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
torchvision/models/optical_flow/raft.py
torchvision/models/optical_flow/raft.py
+13
-0
No files found.
torchvision/models/optical_flow/raft.py
View file @
b06ea39d
...
@@ -369,6 +369,19 @@ class CorrBlock(nn.Module):
...
@@ -369,6 +369,19 @@ class CorrBlock(nn.Module):
raise
ValueError
(
raise
ValueError
(
f
"Input feature maps should have the same shape, instead got
{
fmap1
.
shape
}
(fmap1.shape) !=
{
fmap2
.
shape
}
(fmap2.shape)"
f
"Input feature maps should have the same shape, instead got
{
fmap1
.
shape
}
(fmap1.shape) !=
{
fmap2
.
shape
}
(fmap2.shape)"
)
)
# Explaining min_fmap_size below: the fmaps are down-sampled (num_levels - 1) times by a factor of 2.
# The last corr_volume most have at least 2 values (hence the 2* factor), otherwise grid_sample() would
# produce nans in its output.
min_fmap_size
=
2
*
(
2
**
(
self
.
num_levels
-
1
))
if
any
(
fmap_size
<
min_fmap_size
for
fmap_size
in
fmap1
.
shape
[
-
2
:]):
raise
ValueError
(
"Feature maps are too small to be down-sampled by the correlation pyramid. "
f
"H and W of feature maps should be at least
{
min_fmap_size
}
; got:
{
fmap1
.
shape
[
-
2
:]
}
. "
"Remember that input images to the model are downsampled by 8, so that means their "
f
"dimensions should be at least 8 *
{
min_fmap_size
}
=
{
8
*
min_fmap_size
}
."
)
corr_volume
=
self
.
_compute_corr_volume
(
fmap1
,
fmap2
)
corr_volume
=
self
.
_compute_corr_volume
(
fmap1
,
fmap2
)
batch_size
,
h
,
w
,
num_channels
,
_
,
_
=
corr_volume
.
shape
# _, _ = h, w
batch_size
,
h
,
w
,
num_channels
,
_
,
_
=
corr_volume
.
shape
# _, _ = h, w
...
...
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