Spaces:
Runtime error
Runtime error
Download src/preprocessing.py from XDL-Collitis/XDL-Colitis-Demo: direct link, hf CLI and curl.
- Browser
- Download file 523 Bytes
-
https://huggingface.co/spaces/XDL-Collitis/XDL-Colitis-Demo/resolve/main/src/preprocessing.py
- Command line
-
hf download hf://spaces/XDL-Collitis/XDL-Colitis-Demo/src/preprocessing.py
-
curl -L -o preprocessing.py https://huggingface.co/spaces/XDL-Collitis/XDL-Colitis-Demo/resolve/main/src/preprocessing.py
523 Bytes
| from typing import Sequence | |
| import torchvision.transforms as transforms | |
| def preprocess(target_input_size: Sequence[int]) -> transforms.Compose: | |
| """Return the inference transform used by the demo model.""" | |
| if not (isinstance(target_input_size, (list, tuple)) and len(target_input_size) == 3): | |
| raise ValueError("target_input_size must be (C, H, W)") | |
| _, height, width = target_input_size | |
| return transforms.Compose([ | |
| transforms.Resize((height, width)), | |
| transforms.ToTensor(), | |
| ]) | |