Spaces:
Running on Zero
Running on Zero
| """Runtime installation of the gigacheck package without its pinned deps. | |
| gigacheck pins ``torch==2.3.1`` in its ``install_requires``, which conflicts | |
| with the ``torch==2.8.0`` this demo needs. Installing gigacheck with | |
| ``--no-deps`` lets pip skip that pin entirely; the inference path only needs | |
| ``numpy``, ``scipy``, ``dacite`` and ``omegaconf`` on top of torch/transformers, | |
| which are declared in ``requirements.txt`` and installed normally. | |
| """ | |
| from __future__ import annotations | |
| import importlib.util | |
| import subprocess | |
| import sys | |
| from loguru import logger | |
| GIGACHECK_SPEC = "git+https://github.com/ai-forever/gigacheck" | |
| def ensure_gigacheck() -> None: | |
| """Install the gigacheck package on first run, skipping its pinned deps. | |
| No-op when gigacheck is already importable (e.g. installed in the image), | |
| so repeated app restarts do not reinstall it. | |
| """ | |
| if importlib.util.find_spec("gigacheck") is not None: | |
| return | |
| logger.info("Installing gigacheck with --no-deps from {}", GIGACHECK_SPEC) | |
| subprocess.run( | |
| [sys.executable, "-m", "pip", "install", "--no-deps", GIGACHECK_SPEC], | |
| check=True, | |
| ) | |