Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ from argparse import ArgumentParser
|
|
4 |
from loguru import logger
|
5 |
from tools.llama.generate import launch_thread_safe_queue
|
6 |
from tools.vqgan.inference import load_model as load_decoder_model
|
7 |
-
|
8 |
|
9 |
def parse_args():
|
10 |
parser = ArgumentParser()
|
@@ -72,7 +72,20 @@ def inference(
|
|
72 |
# 模拟推理过程
|
73 |
result = f"Processed text: {text}"
|
74 |
return result
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
def main():
|
77 |
args = parse_args()
|
78 |
|
@@ -110,8 +123,8 @@ def main():
|
|
110 |
|
111 |
logger.info("Warming up done, launching the web UI...")
|
112 |
|
113 |
-
# Launch the Gradio app
|
114 |
-
app = build_app()
|
115 |
app.launch(show_api=True)
|
116 |
|
117 |
|
|
|
4 |
from loguru import logger
|
5 |
from tools.llama.generate import launch_thread_safe_queue
|
6 |
from tools.vqgan.inference import load_model as load_decoder_model
|
7 |
+
import gradio as gr # 导入 Gradio
|
8 |
|
9 |
def parse_args():
|
10 |
parser = ArgumentParser()
|
|
|
72 |
# 模拟推理过程
|
73 |
result = f"Processed text: {text}"
|
74 |
return result
|
75 |
+
|
76 |
+
def inference_function(text):
|
77 |
+
return f"Processed: {text}"
|
78 |
+
|
79 |
+
def build_app(args):
|
80 |
+
with gr.Blocks() as app:
|
81 |
+
gr.Markdown(f"# Fish Speech Inference - Theme: {args.theme}")
|
82 |
+
text_input = gr.Textbox(label="Input Text")
|
83 |
+
output = gr.Textbox(label="Output Text")
|
84 |
+
submit_button = gr.Button("Submit")
|
85 |
+
|
86 |
+
submit_button.click(fn=inference_function, inputs=text_input, outputs=output)
|
87 |
+
return app
|
88 |
+
|
89 |
def main():
|
90 |
args = parse_args()
|
91 |
|
|
|
123 |
|
124 |
logger.info("Warming up done, launching the web UI...")
|
125 |
|
126 |
+
# Launch the Gradio app, passing args to build_app
|
127 |
+
app = build_app(args)
|
128 |
app.launch(show_api=True)
|
129 |
|
130 |
|