Update app.py
Browse files
app.py
CHANGED
@@ -35,7 +35,7 @@ def stop_generation():
|
|
35 |
is_stopped = True
|
36 |
return "Generation stopped."
|
37 |
|
38 |
-
def CTXGen(τ, g_num, length_range
|
39 |
global is_stopped
|
40 |
is_stopped = False # 重置停止标志
|
41 |
start, end = length_range
|
@@ -66,7 +66,7 @@ def CTXGen(τ, g_num, length_range, progress=gr.Progress()):
|
|
66 |
start_time = time.time()
|
67 |
while count < gen_num:
|
68 |
if is_stopped: # 检查是否停止
|
69 |
-
|
70 |
|
71 |
if time.time() - start_time > 1200:
|
72 |
break
|
@@ -84,7 +84,7 @@ def CTXGen(τ, g_num, length_range, progress=gr.Progress()):
|
|
84 |
|
85 |
for i in range(length):
|
86 |
if is_stopped: # 检查是否停止
|
87 |
-
|
88 |
|
89 |
_, idx_seq, idx_msa, attn_idx = get_paded_token_idx_gen(vocab_mlm, seq, new_seq)
|
90 |
idx_seq = torch.tensor(idx_seq).unsqueeze(0).to(device)
|
@@ -140,9 +140,8 @@ def CTXGen(τ, g_num, length_range, progress=gr.Progress()):
|
|
140 |
})
|
141 |
out.to_csv("output.csv", index=False, encoding='utf-8-sig')
|
142 |
count += 1
|
143 |
-
progress(count / gen_num, desc="Generating conotoxins...")
|
144 |
yield out, f"Generated {count} conotoxins."
|
145 |
-
|
146 |
|
147 |
# 使用 gr.Blocks 构建界面
|
148 |
with gr.Blocks() as demo:
|
@@ -161,7 +160,7 @@ with gr.Blocks() as demo:
|
|
161 |
output_file = gr.File(label="Download generated conotoxins")
|
162 |
|
163 |
# 绑定事件
|
164 |
-
start_button.click(CTXGen, inputs=[τ, g_num, length_range], outputs=[output_df, status_text]
|
165 |
stop_button.click(stop_generation, outputs=status_text)
|
166 |
|
167 |
# 启动 Gradio 应用
|
|
|
35 |
is_stopped = True
|
36 |
return "Generation stopped."
|
37 |
|
38 |
+
def CTXGen(τ, g_num, length_range):
|
39 |
global is_stopped
|
40 |
is_stopped = False # 重置停止标志
|
41 |
start, end = length_range
|
|
|
66 |
start_time = time.time()
|
67 |
while count < gen_num:
|
68 |
if is_stopped: # 检查是否停止
|
69 |
+
yield pd.DataFrame(), f"Generation stopped. Generated {count} conotoxins."
|
70 |
|
71 |
if time.time() - start_time > 1200:
|
72 |
break
|
|
|
84 |
|
85 |
for i in range(length):
|
86 |
if is_stopped: # 检查是否停止
|
87 |
+
yield pd.DataFrame(), f"Generation stopped. Generated {count} conotoxins."
|
88 |
|
89 |
_, idx_seq, idx_msa, attn_idx = get_paded_token_idx_gen(vocab_mlm, seq, new_seq)
|
90 |
idx_seq = torch.tensor(idx_seq).unsqueeze(0).to(device)
|
|
|
140 |
})
|
141 |
out.to_csv("output.csv", index=False, encoding='utf-8-sig')
|
142 |
count += 1
|
|
|
143 |
yield out, f"Generated {count} conotoxins."
|
144 |
+
yield out, f"Generated {count} conotoxins."
|
145 |
|
146 |
# 使用 gr.Blocks 构建界面
|
147 |
with gr.Blocks() as demo:
|
|
|
160 |
output_file = gr.File(label="Download generated conotoxins")
|
161 |
|
162 |
# 绑定事件
|
163 |
+
start_button.click(CTXGen, inputs=[τ, g_num, length_range], outputs=[output_df, status_text])
|
164 |
stop_button.click(stop_generation, outputs=status_text)
|
165 |
|
166 |
# 启动 Gradio 应用
|