ChenyangSi commited on
Commit
98d6951
·
1 Parent(s): 34a77d9

Update free_lunch_utils.py

Browse files
Files changed (1) hide show
  1. free_lunch_utils.py +0 -20
free_lunch_utils.py CHANGED
@@ -20,26 +20,6 @@ def isinstance_str(x: object, cls_name: str):
20
  return False
21
 
22
 
23
- def Fourier_filter(x, threshold, scale):
24
- dtype = x.dtype
25
- x = x.type(torch.float32)
26
- # FFT
27
- x_freq = fft.fftn(x, dim=(-2, -1))
28
- x_freq = fft.fftshift(x_freq, dim=(-2, -1))
29
-
30
- B, C, H, W = x_freq.shape
31
- mask = torch.ones((B, C, H, W)).cuda()
32
-
33
- crow, ccol = H // 2, W //2
34
- mask[..., crow - threshold:crow + threshold, ccol - threshold:ccol + threshold] = scale
35
- x_freq = x_freq * mask
36
-
37
- # IFFT
38
- x_freq = fft.ifftshift(x_freq, dim=(-2, -1))
39
- x_filtered = fft.ifftn(x_freq, dim=(-2, -1)).real
40
-
41
- x_filtered = x_filtered.type(dtype)
42
- return x_filtered
43
 
44
 
45
  def register_upblock2d(model):
 
20
  return False
21
 
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
 
25
  def register_upblock2d(model):