Skip to content
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

MaxVit model #6342

Merged
merged 33 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f15fd92
Added maxvit architecture and tests
TeodorPoncu Aug 1, 2022
c5b2839
rebased + addresed comments
TeodorPoncu Aug 5, 2022
5e8a222
Revert "rebased + addresed comments"
TeodorPoncu Aug 5, 2022
aa95139
Re-added model changes after revert
TeodorPoncu Aug 5, 2022
1fddecc
aligned with partial original implementation
TeodorPoncu Sep 14, 2022
b7f0e97
removed submitit script fixed lint
TeodorPoncu Sep 14, 2022
872f40f
mypy fix for too many arguments
TeodorPoncu Sep 14, 2022
f561edf
updated old tests
TeodorPoncu Sep 14, 2022
314b82a
removed per batch lr scheduler and seed setting
TeodorPoncu Sep 16, 2022
a4863e9
removed ontap
TeodorPoncu Sep 16, 2022
c4406e4
Merge branch 'main' into BATERIES]-add-max-vit
TeodorPoncu Sep 16, 2022
2111680
added docs, validated weights
TeodorPoncu Sep 16, 2022
cc51c2b
fixed test expect, moved shape assertions in the begging for torch.fx…
TeodorPoncu Sep 17, 2022
d2dfe71
mypy fix
TeodorPoncu Sep 17, 2022
328f9b6
lint fix
TeodorPoncu Sep 18, 2022
b334b7f
added legacy interface
TeodorPoncu Sep 18, 2022
ebb8c16
added weight link
TeodorPoncu Sep 20, 2022
e281371
Merge branch 'main' into BATERIES]-add-max-vit
TeodorPoncu Sep 20, 2022
20422bc
updated docs
TeodorPoncu Sep 21, 2022
9ad86fe
Merge branch 'BATERIES]-add-max-vit' of https://github.com/pytorch/vi…
TeodorPoncu Sep 21, 2022
775990c
Merge branch 'main' into BATERIES]-add-max-vit
TeodorPoncu Sep 21, 2022
a24e549
Update references/classification/train.py
TeodorPoncu Sep 21, 2022
bb42548
Update torchvision/models/maxvit.py
TeodorPoncu Sep 21, 2022
ed21d3d
adressed comments
TeodorPoncu Sep 21, 2022
09e4ced
Merge branch 'main' into BATERIES]-add-max-vit
TeodorPoncu Sep 22, 2022
521d6d5
update ra_maginuted and augmix_severity default values
TeodorPoncu Sep 22, 2022
79cb004
Merge branch 'BATERIES]-add-max-vit' of https://github.com/pytorch/vi…
TeodorPoncu Sep 22, 2022
97cbcd8
adressed some comments
TeodorPoncu Sep 22, 2022
9fc6a5b
Merge branch 'BATERIES]-add-max-vit' of https://github.com/pytorch/vi…
TeodorPoncu Sep 22, 2022
6b00ca8
remove input_channels parameter
TeodorPoncu Sep 23, 2022
45d3966
Merge branch 'main' into BATERIES]-add-max-vit
TeodorPoncu Sep 23, 2022
2aca920
Merge branch 'main' into BATERIES]-add-max-vit
TeodorPoncu Sep 23, 2022
cab35c1
Merge branch 'main' into BATERIES]-add-max-vit
TeodorPoncu Sep 23, 2022
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
Binary file added test/expect/ModelTester.test_maxvit_t_expect.pkl
Binary file not shown.
39 changes: 39 additions & 0 deletions test/test_architecture_ops.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import unittest

import pytest
import torch

from torchvision.models.maxvit import SwapAxes, WindowDepartition, WindowPartition


class MaxvitTester(unittest.TestCase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that here you are testing specific layers from MaxViT. This is not something we did previously, so perhaps it does need to be on a separate file.

@YosuaMichael any thoughts here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for a pretty late response!
Currently I dont have any opinion how we should test specific layer of the model and I think this is okay. (Need more time to think and discuss whether we should do more of this kind of test or not)

def test_maxvit_window_partition(self):
input_shape = (1, 3, 224, 224)
partition_size = 7

x = torch.randn(input_shape)

partition = WindowPartition(partition_size=7)
departition = WindowDepartition(partition_size=partition_size, n_partitions=(input_shape[3] // partition_size))

assert torch.allclose(x, departition(partition(x)))

def test_maxvit_grid_partition(self):
input_shape = (1, 3, 224, 224)
partition_size = 7

x = torch.randn(input_shape)
partition = torch.nn.Sequential(
WindowPartition(partition_size=(input_shape[3] // partition_size)),
SwapAxes(-2, -3),
)
departition = torch.nn.Sequential(
SwapAxes(-2, -3),
WindowDepartition(partition_size=(input_shape[3] // partition_size), n_partitions=partition_size),
)

assert torch.allclose(x, departition(partition(x)))


if __name__ == "__main__":
pytest.main([__file__])
1 change: 1 addition & 0 deletions torchvision/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
from .vgg import *
from .vision_transformer import *
from .swin_transformer import *
from .maxvit import *
from . import detection, optical_flow, quantization, segmentation, video
from ._api import get_model, get_model_weights, get_weight, list_models
Loading