Spaces:
Runtime error
Runtime error
Download src/services/predictor.py from SiemonCha/ImageTrust-AI: direct link, hf CLI and curl.
- Browser
- Download file 364 Bytes
-
https://huggingface.co/spaces/SiemonCha/ImageTrust-AI/resolve/main/src/services/predictor.py
- Command line
-
hf download hf://spaces/SiemonCha/ImageTrust-AI/src/services/predictor.py
-
curl -L -o predictor.py https://huggingface.co/spaces/SiemonCha/ImageTrust-AI/resolve/main/src/services/predictor.py
364 Bytes
| from src.models.inference import load_model, predict | |
| # Load model once at startup, reuse for all predictions | |
| _model = None | |
| def get_model(): | |
| global _model | |
| if _model is None: | |
| _model = load_model() | |
| return _model | |
| def run_prediction(image_path: str) -> dict: | |
| model = get_model() | |
| result = predict(image_path, model=model) | |
| return result |