techfreakworm commited on
Commit
43575b3
·
unverified ·
1 Parent(s): ce2a030

feat(app): bootstrap gradio blocks with brutalist mono chrome

Browse files
Files changed (1) hide show
  1. app.py +73 -0
app.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ACE Music Studio — Gradio entrypoint.
2
+
3
+ On HF Spaces, `_bootstrap()` runs once on import to mirror the read-only
4
+ preload cache into a writable tree. On Mac/Linux locally, it's a no-op.
5
+ The backend singleton is lazy-loaded on first generation request.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import os
10
+
11
+ # Set MPS fallback BEFORE any torch import path is taken.
12
+ os.environ.setdefault("PYTORCH_ENABLE_MPS_FALLBACK", "1")
13
+
14
+ # Don't pin HF download source — let HF default for both Spaces and local cache.
15
+ os.environ.setdefault("HF_HUB_ENABLE_HF_TRANSFER", "1")
16
+
17
+ import gradio as gr
18
+
19
+ import theme
20
+
21
+ HEADER_HTML = """
22
+ <div class="ams-header">
23
+ <div>
24
+ <div class="ams-brand">ACE Music Studio<span class="ams-brand-period">.</span></div>
25
+ </div>
26
+ <div class="ams-status">ready</div>
27
+ </div>
28
+ """.strip()
29
+
30
+ CTA_HTML = """
31
+ <div class="ams-cta">
32
+ Built with <span class="ams-cta-heart">♥</span>.
33
+ <strong>Drop a like</strong> at the top
34
+ &nbsp;·&nbsp;
35
+ Follow <a href="https://huggingface.co/techfreakworm" target="_blank" rel="noopener noreferrer"><strong>@techfreakworm</strong></a>
36
+ for what's next.
37
+ </div>
38
+ """.strip()
39
+
40
+
41
+ def _bootstrap() -> None:
42
+ """HF Spaces: mirror read-only preload cache into a writable tree.
43
+
44
+ Local Mac/CUDA: no-op. Implemented at M7 when we wire deployment.
45
+ """
46
+ pass
47
+
48
+
49
+ def build_app() -> gr.Blocks:
50
+ with gr.Blocks(theme=theme.build_theme(), css=theme.CSS, title="ACE Music Studio") as demo:
51
+ gr.HTML(HEADER_HTML)
52
+ gr.HTML(CTA_HTML)
53
+
54
+ with gr.Tabs():
55
+ with gr.Tab("🎵 Generate"):
56
+ gr.Markdown("Generate tab placeholder — implemented in M1.")
57
+ with gr.Tab("🎤 Cover"):
58
+ gr.Markdown("Cover tab placeholder — implemented in M3.")
59
+ with gr.Tab("⏩ Extend"):
60
+ gr.Markdown("Extend tab placeholder — implemented in M3.")
61
+ with gr.Tab("✏️ Edit"):
62
+ gr.Markdown("Edit tab placeholder — implemented in M3.")
63
+ with gr.Tab("✍️ Lyrics"):
64
+ gr.Markdown("Lyrics tab placeholder — implemented in M4.")
65
+
66
+ return demo
67
+
68
+
69
+ if __name__ == "__main__":
70
+ _bootstrap()
71
+ demo = build_app()
72
+ demo.queue(default_concurrency_limit=1)
73
+ demo.launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", 7860)))