hwonder commited on
Commit
04417bd
·
1 Parent(s): ed5dd8e

Minimal test app

Browse files
Files changed (1) hide show
  1. app.py +9 -145
app.py CHANGED
@@ -1,162 +1,26 @@
1
  """
2
- StackNet Demo
3
  """
4
 
5
  import gradio as gr
6
 
7
- # Test import of our modules
8
- try:
9
- from src.ui.tabs import create_all_tabs
10
- from src.ui.handlers import Handlers
11
- MODULES_OK = True
12
- except Exception as e:
13
- MODULES_OK = False
14
- IMPORT_ERROR = str(e)
15
-
16
-
17
  def create_demo():
18
  with gr.Blocks(title="StackNet Demo") as demo:
19
  gr.Markdown("# StackNet Demo 1:1 Preview")
 
20
 
21
- if not MODULES_OK:
22
- gr.Markdown(f"**Import Error:** {IMPORT_ERROR}")
23
- return demo
24
-
25
- with gr.Accordion("Settings", open=True):
26
- api_key = gr.Textbox(
27
- label="StackNet Key",
28
- placeholder="Enter your key to enable generation...",
29
- type="password",
30
- value=""
31
- )
32
-
33
- with gr.Tabs():
34
- tabs = create_all_tabs()
35
-
36
- # Collect all buttons to disable when no API key
37
- all_buttons = [
38
- tabs["text_to_music"]["generate_btn"],
39
- tabs["music_to_music"]["cover_btn"],
40
- tabs["music_to_music"]["stems_btn"],
41
- tabs["text_to_image"]["generate_btn"],
42
- tabs["image_to_image"]["edit_btn"],
43
- tabs["text_to_video"]["generate_btn"],
44
- tabs["image_to_video"]["animate_btn"],
45
- ]
46
-
47
- def update_buttons(key):
48
- enabled = bool(key and key.strip())
49
- return [gr.update(interactive=enabled) for _ in all_buttons]
50
-
51
- api_key.change(
52
- fn=update_buttons,
53
- inputs=[api_key],
54
- outputs=all_buttons
55
- )
56
-
57
- # Initially disable all buttons
58
- demo.load(
59
- fn=lambda: [gr.update(interactive=False) for _ in all_buttons],
60
- outputs=all_buttons
61
- )
62
-
63
- # Text to Music
64
- ttm = tabs["text_to_music"]
65
- ttm["generate_btn"].click(
66
- fn=Handlers.generate_music,
67
- inputs=[
68
- ttm["prompt"],
69
- ttm["tags"],
70
- ttm["instrumental"],
71
- ttm["lyrics"],
72
- ttm["title"],
73
- api_key
74
- ],
75
- outputs=[ttm["output_audio"], ttm["status"]]
76
- )
77
 
78
- # Music to Music - Cover
79
- mtm = tabs["music_to_music"]
80
- mtm["cover_btn"].click(
81
- fn=Handlers.create_cover,
82
- inputs=[
83
- mtm["cover_audio_input"],
84
- mtm["cover_style_prompt"],
85
- mtm["cover_tags"],
86
- mtm["cover_title"],
87
- api_key
88
- ],
89
- outputs=[mtm["cover_output"], mtm["cover_status"]]
90
- )
91
-
92
- # Music to Music - Stems
93
- mtm["stems_btn"].click(
94
- fn=Handlers.extract_stems,
95
- inputs=[mtm["stems_audio_input"], api_key],
96
- outputs=[
97
- mtm["vocals_output"],
98
- mtm["drums_output"],
99
- mtm["bass_output"],
100
- mtm["other_output"],
101
- mtm["stems_status"]
102
- ]
103
- )
104
-
105
- # Text to Image
106
- tti = tabs["text_to_image"]
107
- tti["generate_btn"].click(
108
- fn=Handlers.generate_image,
109
- inputs=[
110
- tti["prompt"],
111
- tti["style"],
112
- tti["aspect_ratio"],
113
- api_key
114
- ],
115
- outputs=[tti["output_image"], tti["status"]]
116
- )
117
-
118
- # Image to Image
119
- iti = tabs["image_to_image"]
120
- iti["edit_btn"].click(
121
- fn=Handlers.edit_image,
122
- inputs=[
123
- iti["input_image"],
124
- iti["edit_prompt"],
125
- iti["strength"],
126
- api_key
127
- ],
128
- outputs=[iti["output_image"], iti["status"]]
129
- )
130
-
131
- # Text to Video
132
- ttv = tabs["text_to_video"]
133
- ttv["generate_btn"].click(
134
- fn=Handlers.generate_video,
135
- inputs=[
136
- ttv["prompt"],
137
- ttv["duration"],
138
- ttv["style"],
139
- api_key
140
- ],
141
- outputs=[ttv["output_video"], ttv["status"]]
142
- )
143
-
144
- # Image to Video
145
- itv = tabs["image_to_video"]
146
- itv["animate_btn"].click(
147
- fn=Handlers.animate_image,
148
- inputs=[
149
- itv["input_image"],
150
- itv["motion_prompt"],
151
- itv["duration"],
152
- api_key
153
- ],
154
- outputs=[itv["output_video"], itv["status"]]
155
  )
156
 
157
  return demo
158
 
159
-
160
  demo = create_demo()
161
 
162
  if __name__ == "__main__":
 
1
  """
2
+ StackNet Demo - Minimal Test
3
  """
4
 
5
  import gradio as gr
6
 
 
 
 
 
 
 
 
 
 
 
7
  def create_demo():
8
  with gr.Blocks(title="StackNet Demo") as demo:
9
  gr.Markdown("# StackNet Demo 1:1 Preview")
10
+ gr.Markdown("Testing basic functionality...")
11
 
12
+ test_input = gr.Textbox(label="Test Input", placeholder="Type something...")
13
+ test_output = gr.Textbox(label="Test Output")
14
+ test_btn = gr.Button("Test", variant="primary")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ test_btn.click(
17
+ fn=lambda x: f"You typed: {x}",
18
+ inputs=[test_input],
19
+ outputs=[test_output]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  )
21
 
22
  return demo
23
 
 
24
  demo = create_demo()
25
 
26
  if __name__ == "__main__":