Download src/transforms.py from 2Dmatters/Elf_encoder: direct link, hf CLI and curl.
- Browser
- Download file 327 Bytes
-
https://huggingface.co/2Dmatters/Elf_encoder/resolve/main/src/transforms.py
- Command line
-
hf download hf://2Dmatters/Elf_encoder/src/transforms.py
-
curl -L -o transforms.py https://huggingface.co/2Dmatters/Elf_encoder/resolve/main/src/transforms.py
327 Bytes
| #!/usr/bin/env python | |
| """ | |
| Transforms for images applied using fastai dataloaders. | |
| """ | |
| from fastai import * | |
| from fastai.vision.all import * | |
| class Binarize(Transform): | |
| def __init__(self, threshold=0.8):self.threshold=threshold | |
| def encodes(self, o): | |
| mask = (o > (255 * self.threshold)) | |
| return mask * 255 |