Spaces:
Running on Zero
Running on Zero
Vicente Alvarez commited on
Commit ·
4ac107d
1
Parent(s): ee79f31
Fix: use torchvision.transforms.functional.gaussian_blur
Browse files
app.py
CHANGED
|
@@ -228,15 +228,15 @@ def apply_gaussian_blur(video_tensor: torch.Tensor, blur_amount: int) -> torch.T
|
|
| 228 |
if blur_amount <= 0:
|
| 229 |
return video_tensor
|
| 230 |
|
| 231 |
-
|
| 232 |
|
| 233 |
# Ensure kernel size is odd and at least 3
|
| 234 |
kernel_size = blur_amount * 2 + 1
|
| 235 |
sigma = blur_amount / 2.0
|
| 236 |
|
| 237 |
-
#
|
| 238 |
# Our video is [frames, channels, H, W] which works directly
|
| 239 |
-
blurred =
|
| 240 |
|
| 241 |
return blurred
|
| 242 |
|
|
|
|
| 228 |
if blur_amount <= 0:
|
| 229 |
return video_tensor
|
| 230 |
|
| 231 |
+
from torchvision.transforms.functional import gaussian_blur
|
| 232 |
|
| 233 |
# Ensure kernel size is odd and at least 3
|
| 234 |
kernel_size = blur_amount * 2 + 1
|
| 235 |
sigma = blur_amount / 2.0
|
| 236 |
|
| 237 |
+
# gaussian_blur expects [batch, channels, H, W] or [channels, H, W]
|
| 238 |
# Our video is [frames, channels, H, W] which works directly
|
| 239 |
+
blurred = gaussian_blur(video_tensor, kernel_size=[kernel_size, kernel_size], sigma=[sigma, sigma])
|
| 240 |
|
| 241 |
return blurred
|
| 242 |
|