Spaces:
Running on Zero
Running on Zero
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -18,9 +18,11 @@ A CPU-based Hugging Face Space for generating music using [Stability AI's Stable
|
|
| 18 |
- **Model**: `small-music` (433M parameters)
|
| 19 |
- **Duration**: 1–120 seconds
|
| 20 |
- **Sample rate**: 44.1 kHz stereo
|
| 21 |
-
- **Runs on CPU** (no GPU
|
| 22 |
- Gradio 6.3.0 interface
|
| 23 |
|
|
|
|
|
|
|
| 24 |
## Usage
|
| 25 |
|
| 26 |
1. Enter a text prompt describing the music you want
|
|
|
|
| 18 |
- **Model**: `small-music` (433M parameters)
|
| 19 |
- **Duration**: 1–120 seconds
|
| 20 |
- **Sample rate**: 44.1 kHz stereo
|
| 21 |
+
- **Runs on CPU** (only a 1s ZeroGPU touch at startup; no GPU quota used per request)
|
| 22 |
- Gradio 6.3.0 interface
|
| 23 |
|
| 24 |
+
This Space is configured for CPU inference. ZeroGPU Spaces fail to boot unless at least one `spaces.GPU` function is called, so `app.py` calls one minimal `@spaces.GPU(duration=1)` function a single time at startup. Keep every other function (especially generation) undecorated so no GPU allocation happens per request.
|
| 25 |
+
|
| 26 |
## Usage
|
| 27 |
|
| 28 |
1. Enter a text prompt describing the music you want
|
app.py
CHANGED
|
@@ -13,21 +13,22 @@ if hf_token:
|
|
| 13 |
login(token=hf_token)
|
| 14 |
|
| 15 |
|
| 16 |
-
#
|
|
|
|
|
|
|
|
|
|
| 17 |
@spaces.GPU(duration=1)
|
| 18 |
-
def
|
| 19 |
-
return "
|
| 20 |
|
| 21 |
|
| 22 |
-
|
| 23 |
-
_gpu_startup_check()
|
| 24 |
|
| 25 |
|
| 26 |
# Model cache
|
| 27 |
MODEL_CACHE = {}
|
| 28 |
|
| 29 |
|
| 30 |
-
@spaces.GPU(duration=1)
|
| 31 |
def load_model(model_name):
|
| 32 |
"""Load model on demand and cache it."""
|
| 33 |
if model_name not in MODEL_CACHE:
|
|
|
|
| 13 |
login(token=hf_token)
|
| 14 |
|
| 15 |
|
| 16 |
+
# ZeroGPU Spaces refuse to start if no @spaces.GPU function is ever called, but
|
| 17 |
+
# every call into a GPU function burns quota. So call this exactly ONCE at boot
|
| 18 |
+
# with the smallest budget (1s), and keep all real generation on CPU below
|
| 19 |
+
# (NOT decorated). That way quota is only touched here, never per request.
|
| 20 |
@spaces.GPU(duration=1)
|
| 21 |
+
def _gpu_startup_touch():
|
| 22 |
+
return "ok"
|
| 23 |
|
| 24 |
|
| 25 |
+
_gpu_startup_touch()
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
# Model cache
|
| 29 |
MODEL_CACHE = {}
|
| 30 |
|
| 31 |
|
|
|
|
| 32 |
def load_model(model_name):
|
| 33 |
"""Load model on demand and cache it."""
|
| 34 |
if model_name not in MODEL_CACHE:
|