Skip to content

Add support to MViT v1 #6179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ pre-trained weights:
.. toctree::
:maxdepth: 1

models/video_mvitv2
models/video_mvit
models/video_resnet

|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ The MViT V2 model is based on the
Model builders
--------------

The following model builders can be used to instantiate a MViTV2 model, with or
The following model builders can be used to instantiate a MViT model, with or
without pre-trained weights. All the model builders internally rely on the
``torchvision.models.video.MViTV2`` base class. Please refer to the `source
``torchvision.models.video.MViT`` base class. Please refer to the `source
code
<https://github.com/pytorch/vision/blob/main/torchvision/models/video/mvitv2.py>`_ for
<https://github.com/pytorch/vision/blob/main/torchvision/models/video/mvit.py>`_ for
more details about this class.

.. autosummary::
:toctree: generated/
:template: function.rst

mvit_v2_t
mvit_v2_s
mvit_v2_b
mvit_v1_b
5 changes: 3 additions & 2 deletions references/video_classification/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def main(args):
split="train",
step_between_clips=1,
transform=transform_train,
frame_rate=15,
frame_rate=args.frame_rate,
extensions=(
"avi",
"mp4",
Expand Down Expand Up @@ -189,7 +189,7 @@ def main(args):
split="val",
step_between_clips=1,
transform=transform_test,
frame_rate=15,
frame_rate=args.frame_rate,
extensions=(
"avi",
"mp4",
Expand Down Expand Up @@ -324,6 +324,7 @@ def parse_args():
parser.add_argument("--model", default="r2plus1d_18", type=str, help="model name")
parser.add_argument("--device", default="cuda", type=str, help="device (Use cuda or cpu Default: cuda)")
parser.add_argument("--clip-len", default=16, type=int, metavar="N", help="number of frames per clip")
parser.add_argument("--frame-rate", default=15, type=int, metavar="N", help="the frame rate")
parser.add_argument(
"--clips-per-video", default=5, type=int, metavar="N", help="maximum number of clips per video to consider"
)
Expand Down
Binary file not shown.
Binary file removed test/expect/ModelTester.test_mvit_v2_t_expect.pkl
Binary file not shown.
4 changes: 3 additions & 1 deletion test/test_extended_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def test_transforms_jit(model_fn):
"input_shape": (1, 3, 520, 520),
},
"video": {
"input_shape": (1, 4, 3, 112, 112),
"input_shape": (1, 3, 4, 112, 112),
},
"optical_flow": {
"input_shape": (1, 3, 128, 128),
Expand All @@ -195,6 +195,8 @@ def test_transforms_jit(model_fn):
if module_name == "optical_flow":
args = (x, x)
else:
if module_name == "video":
x = x.permute(0, 2, 1, 3, 4)
args = (x,)

problematic_weights = []
Expand Down
9 changes: 1 addition & 8 deletions test/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,9 @@ def _check_input_backprop(model, inputs):
"image_size": 56,
"input_shape": (1, 3, 56, 56),
},
"mvit_v2_t": {
"mvit_v1_b": {
"input_shape": (1, 3, 16, 224, 224),
},
"mvit_v2_s": {
"input_shape": (1, 3, 16, 224, 224),
},
"mvit_v2_b": {
"input_shape": (1, 3, 32, 224, 224),
},
}
# speeding up slow models:
slow_models = [
Expand Down Expand Up @@ -347,7 +341,6 @@ def _check_input_backprop(model, inputs):
skipped_big_models = {
"vit_h_14",
"regnet_y_128gf",
"mvit_v2_b",
}

# The following contains configuration and expected values to be used tests that are model specific
Expand Down
2 changes: 1 addition & 1 deletion torchvision/models/video/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .mvitv2 import *
from .mvit import *
from .resnet import *
Loading