Spaces:
Runtime error
Runtime error
Maximilian Schuh
Pin huggingface_hub version to <1.0.0 to avoid import errors with Gradio OAuth
b57bea1 | title: TwinBooster | |
| emoji: 👁️ | |
| colorFrom: gray | |
| colorTo: indigo | |
| sdk: gradio | |
| sdk_version: 4.44.1 | |
| app_file: app.py | |
| pinned: false | |
| python_version: 3.10 | |
| ## Local development | |
| Install dependencies (Python 3.9+ recommended): | |
| ``` | |
| py -3 -m pip install -r requirements.txt | |
| ``` | |
| Run the Gradio demo: | |
| ``` | |
| py -3 app.py | |
| ``` | |
| Usage: | |
| - Paste SMILES (one per line) and a bioassay description, then click **Run prediction**. | |
| - Use **Download / refresh models** if the pretrained weights are not present yet. | |
| - Download predictions as CSV or Excel from the output panel. | |
| Weights: | |
| - All weights are pulled from public Hugging Face repos on first run and cached under `~/.cache/twinbooster`: | |
| - Text encoder: `mschuh/PubChemDeBERTa-augmented` | |
| - LightGBM model: `HF_LGBM_REPO` env var (defaults to `mschuh/TwinBooster-lgbm`) | |
| - Barlow Twins model: `HF_BT_REPO` env var (defaults to `mschuh/TwinBooster-bt`) | |
| - If the repos are public on HF LFS, no additional setup is required on Spaces; downloads are automatic and reused on subsequent runs. | |
| ## ZeroGPU setup (Hugging Face Spaces) | |
| - In the Space settings, choose the **ZeroGPU** hardware tier and Python **3.10** or **3.12** (both supported on ZeroGPU). | |
| - The GPU workload is isolated in `_gpu_predict`, decorated with `@spaces.GPU(duration=120)`, so a GPU is provisioned only for the inference step. | |
| - Queueing is enabled with a single worker (`demo.queue(concurrency_count=1)`) to match the one-at-a-time ZeroGPU execution model. | |
| - To avoid spending GPU time on downloads, click **Download / refresh models** once after each deployment to prefetch weights on CPU. | |
| - If inference ever needs more time, adjust the `duration` parameter in `app.py`, but keep it as low as practical to respect ZeroGPU queue fairness. | |
| - A lightweight, bundled `twinbooster` shim (version `0.3.1`) is shipped in `./twinbooster/` to avoid PyPI's Python 3.8 restriction on the official wheels. No external install is required; the public API used by the app is preserved. | |
| - `huggingface_hub` is pinned to `<1.0.0` because Gradio OAuth still imports `HfFolder`, which was removed in 1.x; keep this constraint to avoid startup import errors on ZeroGPU. | |