oucgc1996 commited on
Commit
0d11814
Β·
verified Β·
1 Parent(s): 3d629b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -65,7 +65,7 @@ def CTXGen(Ο„, g_num, length_range, model_name):
65
  while count < gen_num:
66
  new_seq = None
67
  if is_stopped:
68
- return pd.DataFrame(), "output.csv"
69
 
70
  if time.time() - start_time > 1200:
71
  break
@@ -83,7 +83,7 @@ def CTXGen(Ο„, g_num, length_range, model_name):
83
 
84
  for i in range(length):
85
  if is_stopped:
86
- return pd.DataFrame(), "output.csv"
87
 
88
  _, idx_seq, idx_msa, attn_idx = get_paded_token_idx_gen(vocab_mlm, seq, new_seq)
89
  idx_seq = torch.tensor(idx_seq).unsqueeze(0).to(device)
@@ -143,10 +143,14 @@ def CTXGen(Ο„, g_num, length_range, model_name):
143
  })
144
  out.to_csv("output.csv", index=False, encoding='utf-8-sig')
145
  count += 1
146
- yield out, "output.csv"
147
- return out, "output.csv"
148
 
149
  with gr.Blocks() as demo:
 
 
 
 
150
  gr.Markdown("# Conotoxin Unconstrained Generation")
151
  gr.Markdown("#### Input")
152
  gr.Markdown("βœ…**Ο„**: temperature factor controls the diversity of conotoxins generated. The higher the value, the higher the diversity")
@@ -161,12 +165,12 @@ with gr.Blocks() as demo:
161
  with gr.Row():
162
  start_button = gr.Button("Start Generation")
163
  stop_button = gr.Button("Stop Generation")
164
- with gr.Row():
165
- output_df = gr.DataFrame(label="Generated Conotoxins")
166
  with gr.Row():
167
  output_file = gr.File(label="Download generated conotoxins")
168
-
169
- start_button.click(CTXGen, inputs=[Ο„, g_num, length_range, model_name], outputs=[output_df, output_file])
 
 
170
  stop_button.click(stop_generation, outputs=None)
171
 
172
  demo.launch()
 
65
  while count < gen_num:
66
  new_seq = None
67
  if is_stopped:
68
+ return "output.csv", pd.DataFrame()
69
 
70
  if time.time() - start_time > 1200:
71
  break
 
83
 
84
  for i in range(length):
85
  if is_stopped:
86
+ return "output.csv", pd.DataFrame()
87
 
88
  _, idx_seq, idx_msa, attn_idx = get_paded_token_idx_gen(vocab_mlm, seq, new_seq)
89
  idx_seq = torch.tensor(idx_seq).unsqueeze(0).to(device)
 
143
  })
144
  out.to_csv("output.csv", index=False, encoding='utf-8-sig')
145
  count += 1
146
+ yield "output.csv", out
147
+ return "output.csv", out
148
 
149
  with gr.Blocks() as demo:
150
+ gr.Markdown("πŸ”— **[Label Prediction](https://huggingface.co/spaces/oucgc1996/CTXGen_Label_Prediction)**")
151
+ gr.Markdown("πŸ”— **[Unconstrained Generation](https://huggingface.co/spaces/oucgc1996/CTXGen_Unconstrained_generation)**")
152
+ gr.Markdown("πŸ”— **[Conditional Generation](https://huggingface.co/spaces/oucgc1996/CTXGen_conditional_generation)**")
153
+ gr.Markdown("πŸ”— **[Optimization Generation](https://huggingface.co/spaces/oucgc1996/CTXGen_optimization_generation)**")
154
  gr.Markdown("# Conotoxin Unconstrained Generation")
155
  gr.Markdown("#### Input")
156
  gr.Markdown("βœ…**Ο„**: temperature factor controls the diversity of conotoxins generated. The higher the value, the higher the diversity")
 
165
  with gr.Row():
166
  start_button = gr.Button("Start Generation")
167
  stop_button = gr.Button("Stop Generation")
 
 
168
  with gr.Row():
169
  output_file = gr.File(label="Download generated conotoxins")
170
+ with gr.Row():
171
+ output_df = gr.DataFrame(label="Generated Conotoxins")
172
+
173
+ start_button.click(CTXGen, inputs=[Ο„, g_num, length_range, model_name], outputs=[output_file, output_df])
174
  stop_button.click(stop_generation, outputs=None)
175
 
176
  demo.launch()