# startup_patch.py — imported at the end of app.py to override render_full_set # This ensures the Gradio app uses demucs + stem_mixer for rendering import sys import os sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from stem_render import render_full_set_with_stems def patch_render(): """Override the render_full_set function to use stems.""" import app as _app # Store reference to app_state _app_state = _app.app_state # Create wrapper that passes app_state def _patched_render(progress=None): import gradio as gr if progress is None: progress = gr.Progress() return render_full_set_with_stems(_app_state, progress) # Replace the function in the module _app.render_full_set = _patched_render # Also update the Gradio click handler if already connected print("[startup_patch] render_full_set patched to use demucs + stem_mixer") # Auto-patch on import try: patch_render() except Exception as e: print(f"[startup_patch] Warning: could not patch render_full_set: {e}")