Download app/models/DEEP_STEGO/Utils/preprocessing.py from savetrees/StegNet: direct link, hf CLI and curl.
- Browser
- Download file 487 Bytes
-
https://huggingface.co/spaces/savetrees/StegNet/resolve/main/app/models/DEEP_STEGO/Utils/preprocessing.py
- Command line
-
hf download hf://spaces/savetrees/StegNet/app/models/DEEP_STEGO/Utils/preprocessing.py
-
curl -L -o preprocessing.py https://huggingface.co/spaces/savetrees/StegNet/resolve/main/app/models/DEEP_STEGO/Utils/preprocessing.py
487 Bytes
| import numpy as np | |
| # Preprocessing functions | |
| def normalize_batch(images): | |
| """Performs channel-wise z-score normalization""" | |
| return (images - np.array([0.485, 0.456, 0.406])) / np.array([0.229, 0.224, 0.225]) | |
| def denormalize_batch(images, should_clip=True): | |
| """Denormalize the images for prediction""" | |
| images = (images * np.array([0.229, 0.224, 0.225])) + np.array([0.485, 0.456, 0.406]) | |
| if should_clip: | |
| images = np.clip(images, 0, 1) | |
| return images | |