Spaces:
Sleeping
Sleeping
Download src/modelCache.py from lbmodelscom/faster-whisper-webui: direct link, hf CLI and curl.
- Browser
- Download file 501 Bytes
-
https://huggingface.co/spaces/lbmodelscom/faster-whisper-webui/resolve/main/src/modelCache.py
- Command line
-
hf download hf://spaces/lbmodelscom/faster-whisper-webui/src/modelCache.py
-
curl -L -o modelCache.py https://huggingface.co/spaces/lbmodelscom/faster-whisper-webui/resolve/main/src/modelCache.py
501 Bytes
| class ModelCache: | |
| def __init__(self): | |
| self._cache = dict() | |
| def get(self, model_key: str, model_factory): | |
| result = self._cache.get(model_key) | |
| if result is None: | |
| result = model_factory() | |
| self._cache[model_key] = result | |
| return result | |
| def clear(self): | |
| self._cache.clear() | |
| # A global cache of models. This is mainly used by the daemon processes to avoid loading the same model multiple times. | |
| GLOBAL_MODEL_CACHE = ModelCache() |