Ace-Step-Munk / app.py
OnyxlMunkey's picture
Initialize 5Hz LM on Space startup (ACESTEP_INIT_LLM env, default true)
b7756c5
"""
Hugging Face Space entry point for ACE-Step 1.5.
Run the Gradio app bound to 0.0.0.0:7860 and with init_service so models load on startup.
"""
import os
import sys
# Mandatory HF Spaces GPU fix: spaces MUST be imported before any CUDA-related package
try:
import spaces # noqa: F401
except ImportError:
pass
if os.environ.get("SPACE_ID"):
os.environ.setdefault("ACCELERATE_DISABLE_RICH", "1")
os.environ.setdefault("ACESTEP_COMPILE_MODEL", "0")
# Ensure this repo root is on path (Space repo contains app.py + acestep/ at same level)
_REPO_ROOT = os.path.dirname(os.path.abspath(__file__))
if _REPO_ROOT not in sys.path:
sys.path.insert(0, _REPO_ROOT)
# Override argv for Space: bind all interfaces, port 7860, init service
os.chdir(_REPO_ROOT)
argv = [
sys.argv[0],
"--server-name", "0.0.0.0",
"--port", "7860",
"--init_service", "true",
"--config_path", "acestep-v15-turbo",
"--download-source", "huggingface",
]
# Initialize 5Hz LM by default in Space (set ACESTEP_INIT_LLM=false in Settings to disable and save VRAM)
_init_lm = os.environ.get("ACESTEP_INIT_LLM", "").strip().lower()
if _init_lm in ("", "1", "true", "yes", "y", "on", "auto"):
argv.extend(["--init_llm", "true"])
elif _init_lm in ("0", "false", "no", "n", "off"):
argv.extend(["--init_llm", "false"])
sys.argv = argv
from acestep.acestep_v15_pipeline import main
if __name__ == "__main__":
main()