Download augment/augment.py from Sijuade/S12: direct link, hf CLI and curl.
- Browser
- Download file 674 Bytes
-
https://huggingface.co/spaces/Sijuade/S12/resolve/main/augment/augment.py
- Command line
-
hf download hf://spaces/Sijuade/S12/augment/augment.py
-
curl -L -o augment.py https://huggingface.co/spaces/Sijuade/S12/resolve/main/augment/augment.py
674 Bytes
| import torch | |
| import torch.nn as nn | |
| import albumentations as A | |
| from albumentations.pytorch import ToTensorV2 | |
| def get_transforms(means, stds): | |
| train_transforms = A.Compose( | |
| [ | |
| A.Normalize(mean=means, std=stds, always_apply=True), | |
| A.PadIfNeeded(min_height=36, min_width=36, always_apply=True), | |
| A.RandomCrop(height=32, width=32, always_apply=True), | |
| A.HorizontalFlip(), | |
| A.Cutout (fill_value=means), | |
| ToTensorV2(), | |
| ] | |
| ) | |
| test_transforms = A.Compose( | |
| [ | |
| A.Normalize(mean=means, std=stds, always_apply=True), | |
| ToTensorV2(), | |
| ] | |
| ) | |
| return(train_transforms, test_transforms) |