Commit
·
c3b823e
1
Parent(s):
3ec99fb
no changes
Browse files
app.py
CHANGED
@@ -97,12 +97,15 @@ def generate_localized_noise(shape, radius=5):
|
|
97 |
# Crear máscara circular
|
98 |
yy, xx = torch.meshgrid(torch.arange(H), torch.arange(W), indexing='ij')
|
99 |
center_y, center_x = H // 2, W // 2
|
100 |
-
mask = ((yy - center_y)**2 + (xx - center_x)**2)
|
101 |
mask = mask.float().unsqueeze(0).unsqueeze(0) # (1, 1, H, W)
|
102 |
|
103 |
# Aplicar máscara a ruido
|
104 |
noise = torch.randn(B, C, H, W)
|
105 |
localized_noise = noise * mask + -1*(1-mask) # solo hay ruido dentro del círculo
|
|
|
|
|
|
|
106 |
return localized_noise
|
107 |
|
108 |
|
|
|
97 |
# Crear máscara circular
|
98 |
yy, xx = torch.meshgrid(torch.arange(H), torch.arange(W), indexing='ij')
|
99 |
center_y, center_x = H // 2, W // 2
|
100 |
+
mask = ((yy - center_y)**2 + (xx - center_x)**2) <= radius**2
|
101 |
mask = mask.float().unsqueeze(0).unsqueeze(0) # (1, 1, H, W)
|
102 |
|
103 |
# Aplicar máscara a ruido
|
104 |
noise = torch.randn(B, C, H, W)
|
105 |
localized_noise = noise * mask + -1*(1-mask) # solo hay ruido dentro del círculo
|
106 |
+
#mask = ((yy - center_y)**2 + (xx - center_x)**2) >= (radius//2)**2
|
107 |
+
#mask = mask.float().unsqueeze(0).unsqueeze(0) # (1, 1, H, W)
|
108 |
+
#localized_noise = localized_noise * mask + -1*(1-mask) # solo hay ruido dentro del círculo
|
109 |
return localized_noise
|
110 |
|
111 |
|