Skip to content

Commit

Permalink
[Fix] fix ut and hog_layer.
Browse files Browse the repository at this point in the history
  • Loading branch information
daidaiershidi committed Sep 15, 2022
1 parent f996da1 commit fbf1e11
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
6 changes: 3 additions & 3 deletions mmselfsup/datasets/pipelines/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,10 @@ def __repr__(self):

@PIPELINES.register_module()
class MaskfeatMaskGenerator(object):
"""Generate random block mask for each image. This module is used in
Maskfeat to generate masks. This code is borrowed from.
"""Generate random block mask for each image.
<https://github.com/facebookresearch/SlowFast/blob/main/slowfast/datasets/transform.py>
This module is borrowed from
https://github.com/facebookresearch/SlowFast/blob/main/slowfast/datasets/transform.py
Args:
mask_window_size (int): Size of input image. Defaults to 14.
mask_ratio (float): The mask ratio of image. Defaults to 0.4.
Expand Down
3 changes: 0 additions & 3 deletions mmselfsup/models/algorithms/maskfeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ def __init__(self,
assert hog_para is not None
self.hog_layer = HOGLayerC(**hog_para)

def init_weights(self) -> None:
super().init_weights()

def extract_feat(self, input: List[torch.Tensor]) -> torch.Tensor:
"""Function to extract features from backbone.
Expand Down
6 changes: 3 additions & 3 deletions mmselfsup/models/utils/hog_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class HOGLayerC(nn.Module):
"""Generate hog feature for each batch images. This module is used in
Maskfeat to generate hog feature. This code is borrowed from.
<https://github.com/facebookresearch/SlowFast/blob/main/slowfast/models/masked.py>
<https://github.com/facebookresearch/SlowFast/blob/main/slowfast/models/operators.py>
Args:
nbins (int): Number of bin. Defaults to 9.
pool (float): Number of cell. Defaults to 8.
Expand All @@ -21,7 +21,7 @@ def __init__(self,
nbins: int = 9,
pool: int = 8,
gaussian_window: int = 16) -> None:
super(HOGLayerC, self).__init__()
super().__init__()
self.nbins = nbins
self.pool = pool
self.pi = math.pi
Expand All @@ -47,7 +47,7 @@ def _gaussian_fn(kernlen: int, std: int) -> torch.Tensor:
return w

gkern1d = _gaussian_fn(kernlen, std)
gkern2d = torch.outer(gkern1d, gkern1d)
gkern2d = gkern1d[:, None] * gkern1d[None, :]
return gkern2d / gkern2d.sum()

def _reshape(self, hog_feat: torch.Tensor) -> torch.Tensor:
Expand Down

0 comments on commit fbf1e11

Please sign in to comment.