Minimal test app
Browse files
app.py
CHANGED
|
@@ -1,156 +1,23 @@
|
|
| 1 |
"""
|
| 2 |
-
StackNet Demo
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
A Gradio-based demo showcasing StackNet's capabilities:
|
| 6 |
-
- Text-to-Music
|
| 7 |
-
- Music-to-Music (Cover Songs, Stem Extraction)
|
| 8 |
-
- Text-to-Image
|
| 9 |
-
- Image-to-Image
|
| 10 |
-
- Text-to-Video
|
| 11 |
-
- Image-to-Video
|
| 12 |
-
|
| 13 |
"""
|
| 14 |
|
| 15 |
import gradio as gr
|
| 16 |
|
| 17 |
-
from src.ui.tabs import create_all_tabs
|
| 18 |
-
from src.ui.handlers import Handlers
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
def create_demo() -> gr.Blocks:
|
| 22 |
-
"""Create the complete Gradio demo application."""
|
| 23 |
-
|
| 24 |
-
with gr.Blocks(
|
| 25 |
-
title="StackNet Demo",
|
| 26 |
-
) as demo:
|
| 27 |
-
|
| 28 |
-
gr.Markdown("""
|
| 29 |
-
# StackNet Demo 1:1 Preview
|
| 30 |
-
|
| 31 |
-
""")
|
| 32 |
-
|
| 33 |
-
with gr.Accordion("Settings", open=False):
|
| 34 |
-
api_key = gr.Textbox(
|
| 35 |
-
label="StackNet Key",
|
| 36 |
-
placeholder="Enter your key (e.g., sn_xxxx...)",
|
| 37 |
-
type="password",
|
| 38 |
-
value=""
|
| 39 |
-
)
|
| 40 |
-
|
| 41 |
-
with gr.Tabs():
|
| 42 |
-
tabs = create_all_tabs()
|
| 43 |
-
|
| 44 |
-
# Wire up event handlers (all use api_name=None to hide from API)
|
| 45 |
-
|
| 46 |
-
# Text to Music
|
| 47 |
-
ttm = tabs["text_to_music"]
|
| 48 |
-
ttm["generate_btn"].click(
|
| 49 |
-
fn=Handlers.generate_music,
|
| 50 |
-
inputs=[
|
| 51 |
-
ttm["prompt"],
|
| 52 |
-
ttm["tags"],
|
| 53 |
-
ttm["instrumental"],
|
| 54 |
-
ttm["lyrics"],
|
| 55 |
-
ttm["title"],
|
| 56 |
-
api_key
|
| 57 |
-
],
|
| 58 |
-
outputs=[ttm["output_audio"], ttm["status"]],
|
| 59 |
-
api_name=None
|
| 60 |
-
)
|
| 61 |
-
|
| 62 |
-
# Music to Music - Cover
|
| 63 |
-
mtm = tabs["music_to_music"]
|
| 64 |
-
mtm["cover_btn"].click(
|
| 65 |
-
fn=Handlers.create_cover,
|
| 66 |
-
inputs=[
|
| 67 |
-
mtm["cover_audio_input"],
|
| 68 |
-
mtm["cover_style_prompt"],
|
| 69 |
-
mtm["cover_tags"],
|
| 70 |
-
mtm["cover_title"],
|
| 71 |
-
api_key
|
| 72 |
-
],
|
| 73 |
-
outputs=[mtm["cover_output"], mtm["cover_status"]],
|
| 74 |
-
api_name=None
|
| 75 |
-
)
|
| 76 |
-
|
| 77 |
-
# Music to Music - Stems
|
| 78 |
-
mtm["stems_btn"].click(
|
| 79 |
-
fn=Handlers.extract_stems,
|
| 80 |
-
inputs=[mtm["stems_audio_input"], api_key],
|
| 81 |
-
outputs=[
|
| 82 |
-
mtm["vocals_output"],
|
| 83 |
-
mtm["drums_output"],
|
| 84 |
-
mtm["bass_output"],
|
| 85 |
-
mtm["other_output"],
|
| 86 |
-
mtm["stems_status"]
|
| 87 |
-
],
|
| 88 |
-
api_name=None
|
| 89 |
-
)
|
| 90 |
-
|
| 91 |
-
# Text to Image
|
| 92 |
-
tti = tabs["text_to_image"]
|
| 93 |
-
tti["generate_btn"].click(
|
| 94 |
-
fn=Handlers.generate_image,
|
| 95 |
-
inputs=[
|
| 96 |
-
tti["prompt"],
|
| 97 |
-
tti["style"],
|
| 98 |
-
tti["aspect_ratio"],
|
| 99 |
-
api_key
|
| 100 |
-
],
|
| 101 |
-
outputs=[tti["output_image"], tti["status"]],
|
| 102 |
-
api_name=None
|
| 103 |
-
)
|
| 104 |
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
iti["edit_btn"].click(
|
| 108 |
-
fn=Handlers.edit_image,
|
| 109 |
-
inputs=[
|
| 110 |
-
iti["input_image"],
|
| 111 |
-
iti["edit_prompt"],
|
| 112 |
-
iti["strength"],
|
| 113 |
-
api_key
|
| 114 |
-
],
|
| 115 |
-
outputs=[iti["output_image"], iti["status"]],
|
| 116 |
-
api_name=None
|
| 117 |
-
)
|
| 118 |
|
| 119 |
-
# Text to Video
|
| 120 |
-
ttv = tabs["text_to_video"]
|
| 121 |
-
ttv["generate_btn"].click(
|
| 122 |
-
fn=Handlers.generate_video,
|
| 123 |
-
inputs=[
|
| 124 |
-
ttv["prompt"],
|
| 125 |
-
ttv["duration"],
|
| 126 |
-
ttv["style"],
|
| 127 |
-
api_key
|
| 128 |
-
],
|
| 129 |
-
outputs=[ttv["output_video"], ttv["status"]],
|
| 130 |
-
api_name=None
|
| 131 |
-
)
|
| 132 |
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
itv["animate_btn"].click(
|
| 136 |
-
fn=Handlers.animate_image,
|
| 137 |
-
inputs=[
|
| 138 |
-
itv["input_image"],
|
| 139 |
-
itv["motion_prompt"],
|
| 140 |
-
itv["duration"],
|
| 141 |
-
api_key
|
| 142 |
-
],
|
| 143 |
-
outputs=[itv["output_video"], itv["status"]],
|
| 144 |
-
api_name=None
|
| 145 |
-
)
|
| 146 |
|
| 147 |
-
|
|
|
|
|
|
|
| 148 |
|
|
|
|
|
|
|
| 149 |
|
| 150 |
if __name__ == "__main__":
|
| 151 |
-
demo =
|
| 152 |
-
demo.launch(
|
| 153 |
-
server_name="0.0.0.0",
|
| 154 |
-
server_port=7860,
|
| 155 |
-
share=False,
|
| 156 |
-
)
|
|
|
|
| 1 |
"""
|
| 2 |
+
StackNet Demo - Minimal test version
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
"""
|
| 4 |
|
| 5 |
import gradio as gr
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
def test_function(text):
|
| 9 |
+
return f"You entered: {text}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
with gr.Blocks(title="StackNet Demo") as demo:
|
| 13 |
+
gr.Markdown("# StackNet Demo 1:1 Preview - Test")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
with gr.Row():
|
| 16 |
+
input_text = gr.Textbox(label="Input")
|
| 17 |
+
output_text = gr.Textbox(label="Output")
|
| 18 |
|
| 19 |
+
btn = gr.Button("Test")
|
| 20 |
+
btn.click(fn=test_function, inputs=[input_text], outputs=[output_text])
|
| 21 |
|
| 22 |
if __name__ == "__main__":
|
| 23 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|