Update app.py
Browse files
app.py
CHANGED
@@ -136,24 +136,23 @@ def CTXGen(τ, g_num, length_range, progress=gr.Progress()):
|
|
136 |
progress(count / gen_num, desc="Generating conotoxins...")
|
137 |
return 'output.csv', f"Generated {count} conotoxins."
|
138 |
|
139 |
-
#
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
gr.Slider(minimum=1, maximum=2, step=0.1, label="τ")
|
144 |
-
gr.Dropdown(choices=[1, 10, 100], label="Number of generations")
|
145 |
-
RangeSlider(minimum=8, maximum=50, step=1, value=(12, 17), label="Length range")
|
146 |
-
|
147 |
-
|
148 |
-
gr.
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
stop_button
|
156 |
-
stop_button.click(stop_generation, outputs=gr.Textbox(label="Status"))
|
157 |
|
158 |
# 启动 Gradio 应用
|
159 |
-
|
|
|
136 |
progress(count / gen_num, desc="Generating conotoxins...")
|
137 |
return 'output.csv', f"Generated {count} conotoxins."
|
138 |
|
139 |
+
# 使用 gr.Blocks 构建界面
|
140 |
+
with gr.Blocks() as demo:
|
141 |
+
gr.Markdown("# Conotoxin Generation")
|
142 |
+
with gr.Row():
|
143 |
+
τ = gr.Slider(minimum=1, maximum=2, step=0.1, label="τ")
|
144 |
+
g_num = gr.Dropdown(choices=[1, 10, 100], label="Number of generations")
|
145 |
+
length_range = RangeSlider(minimum=8, maximum=50, step=1, value=(12, 17), label="Length range")
|
146 |
+
with gr.Row():
|
147 |
+
start_button = gr.Button("Start Generation")
|
148 |
+
stop_button = gr.Button("Stop Generation")
|
149 |
+
with gr.Row():
|
150 |
+
output_file = gr.File(label="Download generated conotoxins")
|
151 |
+
status_text = gr.Textbox(label="Status")
|
152 |
+
|
153 |
+
# 绑定事件
|
154 |
+
start_button.click(CTXGen, inputs=[τ, g_num, length_range], outputs=[output_file, status_text])
|
155 |
+
stop_button.click(stop_generation, outputs=status_text)
|
|
|
156 |
|
157 |
# 启动 Gradio 应用
|
158 |
+
demo.launch()
|