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
775129be
Unverified
Commit
775129be
authored
Nov 17, 2021
by
Vasilis Vryniotis
Committed by
GitHub
Nov 17, 2021
Browse files
Remove non-functional Transforms from presets. (#4952)
parent
4b2ad55f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
23 deletions
+27
-23
torchvision/prototype/models/video/resnet.py
torchvision/prototype/models/video/resnet.py
+3
-3
torchvision/prototype/transforms/_presets.py
torchvision/prototype/transforms/_presets.py
+24
-20
No files found.
torchvision/prototype/models/video/resnet.py
View file @
775129be
...
@@ -62,7 +62,7 @@ _COMMON_META = {
...
@@ -62,7 +62,7 @@ _COMMON_META = {
class
R3D_18Weights
(
Weights
):
class
R3D_18Weights
(
Weights
):
Kinetics400_RefV1
=
WeightEntry
(
Kinetics400_RefV1
=
WeightEntry
(
url
=
"https://download.pytorch.org/models/r3d_18-b3b3357e.pth"
,
url
=
"https://download.pytorch.org/models/r3d_18-b3b3357e.pth"
,
transforms
=
partial
(
Kinect400Eval
,
resize
_size
=
(
12
8
,
1
7
1
),
crop
_size
=
(
1
12
,
11
2
)),
transforms
=
partial
(
Kinect400Eval
,
crop
_size
=
(
1
12
,
11
2
),
resize
_size
=
(
12
8
,
1
7
1
)),
meta
=
{
meta
=
{
**
_COMMON_META
,
**
_COMMON_META
,
"acc@1"
:
52.75
,
"acc@1"
:
52.75
,
...
@@ -74,7 +74,7 @@ class R3D_18Weights(Weights):
...
@@ -74,7 +74,7 @@ class R3D_18Weights(Weights):
class
MC3_18Weights
(
Weights
):
class
MC3_18Weights
(
Weights
):
Kinetics400_RefV1
=
WeightEntry
(
Kinetics400_RefV1
=
WeightEntry
(
url
=
"https://download.pytorch.org/models/mc3_18-a90a0ba3.pth"
,
url
=
"https://download.pytorch.org/models/mc3_18-a90a0ba3.pth"
,
transforms
=
partial
(
Kinect400Eval
,
resize
_size
=
(
12
8
,
1
7
1
),
crop
_size
=
(
1
12
,
11
2
)),
transforms
=
partial
(
Kinect400Eval
,
crop
_size
=
(
1
12
,
11
2
),
resize
_size
=
(
12
8
,
1
7
1
)),
meta
=
{
meta
=
{
**
_COMMON_META
,
**
_COMMON_META
,
"acc@1"
:
53.90
,
"acc@1"
:
53.90
,
...
@@ -86,7 +86,7 @@ class MC3_18Weights(Weights):
...
@@ -86,7 +86,7 @@ class MC3_18Weights(Weights):
class
R2Plus1D_18Weights
(
Weights
):
class
R2Plus1D_18Weights
(
Weights
):
Kinetics400_RefV1
=
WeightEntry
(
Kinetics400_RefV1
=
WeightEntry
(
url
=
"https://download.pytorch.org/models/r2plus1d_18-91a641e6.pth"
,
url
=
"https://download.pytorch.org/models/r2plus1d_18-91a641e6.pth"
,
transforms
=
partial
(
Kinect400Eval
,
resize
_size
=
(
12
8
,
1
7
1
),
crop
_size
=
(
1
12
,
11
2
)),
transforms
=
partial
(
Kinect400Eval
,
crop
_size
=
(
1
12
,
11
2
),
resize
_size
=
(
12
8
,
1
7
1
)),
meta
=
{
meta
=
{
**
_COMMON_META
,
**
_COMMON_META
,
"acc@1"
:
57.50
,
"acc@1"
:
57.50
,
...
...
torchvision/prototype/transforms/_presets.py
View file @
775129be
...
@@ -3,8 +3,7 @@ from typing import Dict, Optional, Tuple
...
@@ -3,8 +3,7 @@ from typing import Dict, Optional, Tuple
import
torch
import
torch
from
torch
import
Tensor
,
nn
from
torch
import
Tensor
,
nn
from
...
import
transforms
as
T
from
...transforms
import
functional
as
F
,
InterpolationMode
from
...transforms
import
functional
as
F
__all__
=
[
"CocoEval"
,
"ImageNetEval"
,
"Kinect400Eval"
,
"VocEval"
]
__all__
=
[
"CocoEval"
,
"ImageNetEval"
,
"Kinect400Eval"
,
"VocEval"
]
...
@@ -26,42 +25,47 @@ class ImageNetEval(nn.Module):
...
@@ -26,42 +25,47 @@ class ImageNetEval(nn.Module):
resize_size
:
int
=
256
,
resize_size
:
int
=
256
,
mean
:
Tuple
[
float
,
...]
=
(
0.485
,
0.456
,
0.406
),
mean
:
Tuple
[
float
,
...]
=
(
0.485
,
0.456
,
0.406
),
std
:
Tuple
[
float
,
...]
=
(
0.229
,
0.224
,
0.225
),
std
:
Tuple
[
float
,
...]
=
(
0.229
,
0.224
,
0.225
),
interpolation
:
T
.
InterpolationMode
=
T
.
InterpolationMode
.
BILINEAR
,
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
)
->
None
:
)
->
None
:
super
().
__init__
()
super
().
__init__
()
self
.
_resize
=
T
.
Resize
(
resize_size
,
interpolation
=
interpolation
)
self
.
_crop_size
=
[
crop_size
]
self
.
_crop
=
T
.
CenterCrop
(
crop_size
)
self
.
_size
=
[
resize_size
]
self
.
_normalize
=
T
.
Normalize
(
mean
=
mean
,
std
=
std
)
self
.
_mean
=
list
(
mean
)
self
.
_std
=
list
(
std
)
self
.
_interpolation
=
interpolation
def
forward
(
self
,
img
:
Tensor
)
->
Tensor
:
def
forward
(
self
,
img
:
Tensor
)
->
Tensor
:
img
=
self
.
_crop
(
self
.
_resize
(
img
))
img
=
F
.
resize
(
img
,
self
.
_size
,
interpolation
=
self
.
_interpolation
)
img
=
F
.
center_crop
(
img
,
self
.
_crop_size
)
if
not
isinstance
(
img
,
Tensor
):
if
not
isinstance
(
img
,
Tensor
):
img
=
F
.
pil_to_tensor
(
img
)
img
=
F
.
pil_to_tensor
(
img
)
img
=
F
.
convert_image_dtype
(
img
,
torch
.
float
)
img
=
F
.
convert_image_dtype
(
img
,
torch
.
float
)
return
self
.
_normalize
(
img
)
img
=
F
.
normalize
(
img
,
mean
=
self
.
_mean
,
std
=
self
.
_std
)
return
img
class
Kinect400Eval
(
nn
.
Module
):
class
Kinect400Eval
(
nn
.
Module
):
def
__init__
(
def
__init__
(
self
,
self
,
resize_size
:
Tuple
[
int
,
int
],
crop_size
:
Tuple
[
int
,
int
],
crop_size
:
Tuple
[
int
,
int
],
resize_size
:
Tuple
[
int
,
int
],
mean
:
Tuple
[
float
,
...]
=
(
0.43216
,
0.394666
,
0.37645
),
mean
:
Tuple
[
float
,
...]
=
(
0.43216
,
0.394666
,
0.37645
),
std
:
Tuple
[
float
,
...]
=
(
0.22803
,
0.22145
,
0.216989
),
std
:
Tuple
[
float
,
...]
=
(
0.22803
,
0.22145
,
0.216989
),
interpolation
:
T
.
InterpolationMode
=
T
.
InterpolationMode
.
BILINEAR
,
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
)
->
None
:
)
->
None
:
super
().
__init__
()
super
().
__init__
()
self
.
_convert
=
T
.
ConvertImageDtype
(
torch
.
float
)
self
.
_crop_size
=
list
(
crop_size
)
self
.
_resize
=
T
.
Resize
(
resize_size
,
interpolation
=
interpolation
)
self
.
_size
=
list
(
resize_size
)
self
.
_normalize
=
T
.
Normalize
(
mean
=
mean
,
std
=
std
)
self
.
_mean
=
list
(
mean
)
self
.
_crop
=
T
.
CenterCrop
(
crop_size
)
self
.
_std
=
list
(
std
)
self
.
_interpolation
=
interpolation
def
forward
(
self
,
vid
:
Tensor
)
->
Tensor
:
def
forward
(
self
,
vid
:
Tensor
)
->
Tensor
:
vid
=
vid
.
permute
(
0
,
3
,
1
,
2
)
# (T, H, W, C) => (T, C, H, W)
vid
=
vid
.
permute
(
0
,
3
,
1
,
2
)
# (T, H, W, C) => (T, C, H, W)
vid
=
self
.
_convert
(
vid
)
vid
=
F
.
resize
(
vid
,
self
.
_size
,
interpolation
=
self
.
_interpolation
)
vid
=
self
.
_resize
(
vid
)
vid
=
F
.
center_crop
(
vid
,
self
.
_crop_size
)
vid
=
self
.
_normalize
(
vid
)
vid
=
F
.
convert_image_dtype
(
vid
,
torch
.
float
)
vid
=
self
.
_crop
(
vi
d
)
vid
=
F
.
normalize
(
vid
,
mean
=
self
.
_mean
,
std
=
self
.
_st
d
)
return
vid
.
permute
(
1
,
0
,
2
,
3
)
# (T, C, H, W) => (C, T, H, W)
return
vid
.
permute
(
1
,
0
,
2
,
3
)
# (T, C, H, W) => (C, T, H, W)
...
@@ -71,8 +75,8 @@ class VocEval(nn.Module):
...
@@ -71,8 +75,8 @@ class VocEval(nn.Module):
resize_size
:
int
,
resize_size
:
int
,
mean
:
Tuple
[
float
,
...]
=
(
0.485
,
0.456
,
0.406
),
mean
:
Tuple
[
float
,
...]
=
(
0.485
,
0.456
,
0.406
),
std
:
Tuple
[
float
,
...]
=
(
0.229
,
0.224
,
0.225
),
std
:
Tuple
[
float
,
...]
=
(
0.229
,
0.224
,
0.225
),
interpolation
:
T
.
InterpolationMode
=
T
.
InterpolationMode
.
BILINEAR
,
interpolation
:
InterpolationMode
=
InterpolationMode
.
BILINEAR
,
interpolation_target
:
T
.
InterpolationMode
=
T
.
InterpolationMode
.
NEAREST
,
interpolation_target
:
InterpolationMode
=
InterpolationMode
.
NEAREST
,
)
->
None
:
)
->
None
:
super
().
__init__
()
super
().
__init__
()
self
.
_size
=
[
resize_size
]
self
.
_size
=
[
resize_size
]
...
...
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