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

added swin swav model #975

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
644cacc
added swin swav model
Feb 7, 2023
1e0c5e0
Merge branch 'master' into feature/add_swav_swin
Borda May 18, 2023
5c5423b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 18, 2023
bd23c27
update mergify team
Borda May 19, 2023
15d8a8e
Merge branch 'master' into feature/add_swav_swin
Borda May 19, 2023
87ae5a0
Merge branch 'master' into feature/add_swav_swin
Borda May 19, 2023
61578c1
Merge branch 'master' into feature/add_swav_swin
Borda May 21, 2023
f7b98c4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 21, 2023
b9ce3ca
added support for torchvision<v0.13.0
May 21, 2023
80f1353
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 21, 2023
2e0a2ac
fixed (line too long ) & undefined name 'output' in swav_swin
May 21, 2023
2b10e69
Merge branch 'feature/add_swav_swin' of github.com:AhmedHamdi101/ligh…
May 21, 2023
21639ac
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 21, 2023
73b3b82
Merge branch 'master' into feature/add_swav_swin
Borda May 29, 2023
a996d22
docs
Borda Jun 30, 2023
4bcd19b
Apply suggestions from code review
Borda Jun 30, 2023
42cd5ae
Merge branch 'master' into feature/add_swav_swin
Borda Jun 30, 2023
8f73b74
precommit
Borda Jun 30, 2023
3e9c303
Merge branch 'feature/add_swav_swin' of https://github.com/AhmedHamdi…
Borda Jun 30, 2023
26437fb
Merge branch 'master' into feature/add_swav_swin
Borda Jun 30, 2023
9b21e3a
Merge branch 'master' into feature/add_swav_swin
Borda Jul 4, 2023
28619e8
swav backbones mapped using dict instead of if-else conditions
Jul 4, 2023
3115053
Fixed bugs resulting from changing variable names in the shifted_wind…
Jul 4, 2023
c7058b6
Added test case on the swin swav architecture
Jul 4, 2023
15da066
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 4, 2023
eb49cda
removed unused imports from test file
Jul 4, 2023
7558fcd
Merge branch 'feature/add_swav_swin' of https://github.com/AhmedHamdi…
Jul 4, 2023
29346e7
changed nmb_prototypes to num_prototypes
Jul 4, 2023
825ba96
add test another test case for swin swav
Jul 5, 2023
83749a2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 5, 2023
e894a2f
added version checking for meshgrid &
Jul 6, 2023
f3a2d91
Merge branch 'feature/add_swav_swin' of https://github.com/AhmedHamdi…
Jul 6, 2023
b9944a3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 6, 2023
803ff9b
changed some lines longer than 120 character
Jul 6, 2023
c4a9558
Merge branch 'feature/add_swav_swin' of github.com:AhmedHamdi101/ligh…
Jul 6, 2023
529c412
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 6, 2023
525f1d1
removed unnecessary "else" from meshgrid function
Jul 6, 2023
83c800b
changed set args.max_steps from None -> -1
Jul 7, 2023
9bb0bb9
Merge branch 'feature/add_swav_swin' of github.com:AhmedHamdi101/ligh…
Jul 7, 2023
9849890
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 7, 2023
28c47e0
Added functions return types &
Jul 7, 2023
7074e17
Merge branch 'feature/add_swav_swin' of github.com:AhmedHamdi101/ligh…
Jul 7, 2023
723c6f0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 7, 2023
cd1de35
changed variable P to Prob
Jul 8, 2023
a8f9b9f
Merge branch 'feature/add_swav_swin' of github.com:AhmedHamdi101/ligh…
Jul 10, 2023
880dab8
Added a compatibility wrapper
Jul 15, 2023
59bbd74
Merge remote-tracking branch 'upstream/master' into feature/add_swav_…
Jul 15, 2023
898b94d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 15, 2023
b1f55fc
changed the condition in requires from utils/_dependency.py
Jul 15, 2023
3187395
Merge branch
Jul 15, 2023
8f03712
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 15, 2023
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
36 changes: 18 additions & 18 deletions src/pl_bolts/models/self_supervised/swav/swav_swin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@

def _log_api_usage_once(obj: Any) -> None:
"""Logs API usage(module and name) within an organization. In a large ecosystem,
it's often useful to track the PyTorch and TorchVision APIs usage. This API provides
the similar functionality to the logging module in the Python stdlib.It can be used
for debugging purpose to log which methods are used and by default it is inactive,
unless the user manually subscribes a logger via the `SetAPIUsageLogger method
<https://github.com/pytorch/pytorch/blob/eb3b9fe719b21fae13c7a7cf3253f970290a573e/c10/util/Logging.cpp#L114>`_.
Please note it is triggered only once for the same API call within a process.
It does not collect any data from open-source users since it is no-op by default.

For more information, please refer to
* PyTorch note: https://pytorch.org/docs/stable/notes/large_scale_deployments.html#api-usage-logging;
* Logging policy: https://github.com/pytorch/vision/issues/5052;

Args:
obj: an object to extract info from.
it's often useful to track the PyTorch and TorchVision APIs usage. This API provides
the similar functionality to the logging module in the Python stdlib.It can be used
for debugging purpose to log which methods are used and by default it is inactive,
unless the user manually subscribes a logger via the `SetAPIUsageLogger method
<https://github.com/pytorch/pytorch/blob/eb3b9fe719b21fae13c7a7cf3253f970290a573e/c10/util/Logging.cpp#L114>`_.
Please note it is triggered only once for the same API call within a process.
It does not collect any data from open-source users since it is no-op by default.

For more information, please refer to
* PyTorch note: https://pytorch.org/docs/stable/notes/large_scale_deployments.html#api-usage-logging;
* Logging policy: https://github.com/pytorch/vision/issues/5052;

Args:
obj: an object to extract info from.
"""
module = obj.__module__
if not module.startswith("torchvision"):
Expand Down Expand Up @@ -104,10 +104,10 @@ class MLP(torch.nn.Sequential):
If ``None`` this layer won't be used.
activation_layer:
Activation function which will be stacked on top of the normalization layer (if not None),
otherwise on top of the linear layer.
otherwise on top of the linear layer.
If ``None`` this layer won't be used. Default: ``torch.nn.ReLU``
inplace: Parameter for the activation layer, which can optionally do the operation in-place.
Default is ``None``, which uses the respective default values of the ``activation_layer``
Default is ``None``, which uses the respective default values of the ``activation_layer``
and Dropout layer.
bias: Whether to use bias in the linear layer. Default ``True``
dropout: The probability for the dropout layer. Default: 0.0
Expand Down Expand Up @@ -410,7 +410,7 @@ def define_relative_position_index(self):

def get_relative_position_bias(self) -> torch.Tensor:
return _get_relative_position_bias(
self.relative_position_bias_table, self.relative_position_index, self.window_size # type: ignore[arg-type]
self.relative_position_bias_table, self.relative_position_index, self.window_size # type: ignore[arg-type]
)

def forward(self, x: Tensor):
Expand Down Expand Up @@ -475,7 +475,7 @@ def define_relative_position_bias_table(self):
relative_coords_h = torch.arange(-(self.window_size[0] - 1), self.window_size[0], dtype=torch.float32)
relative_coords_w = torch.arange(-(self.window_size[1] - 1), self.window_size[1], dtype=torch.float32)
relative_coords_table = torch.stack(meshgrid([relative_coords_h, relative_coords_w], indexing="ij"))
relative_coords_table = relative_coords_table.permute(1, 2, 0).contiguous().unsqueeze(0)# 1,2*Wh-1,2*Ww-1,2
relative_coords_table = relative_coords_table.permute(1, 2, 0).contiguous().unsqueeze(0) # 1,2*Wh-1,2*Ww-1,2

relative_coords_table[:, :, :, 0] /= self.window_size[0] - 1
relative_coords_table[:, :, :, 1] /= self.window_size[1] - 1
Expand Down