Spaces:
Runtime error
Runtime error
AbelGAlem
feat(server): implement FastAPI application with model loading(HF HUB), CORS support, prediction endpoint and Docker
a65c9ed Download app/utils.py from HelloWorld47474747/ScanServer: direct link, hf CLI and curl.
- Browser
- Download file 509 Bytes
-
https://huggingface.co/spaces/HelloWorld47474747/ScanServer/resolve/main/app/utils.py
- Command line
-
hf download hf://spaces/HelloWorld47474747/ScanServer/app/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/HelloWorld47474747/ScanServer/resolve/main/app/utils.py
509 Bytes
| import json | |
| import numpy as np | |
| from typing import Optional | |
| def load_json(path: str) -> dict: | |
| """Load JSON file.""" | |
| with open(path, "r") as f: | |
| return json.load(f) | |
| def normalize_age(age: Optional[float], amin: float, amax: float, amean: float) -> float: | |
| """Normalize age to [0, 1] range.""" | |
| if age is None: | |
| age = amean | |
| try: | |
| age = float(age) | |
| except Exception: | |
| age = amean | |
| if amax == amin: | |
| return 0.0 | |
| return (age - amin) / (amax - amin) | |