colbyford commited on
Commit
4d5beeb
1 Parent(s): 6d55e92

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -22
app.py CHANGED
@@ -1,10 +1,14 @@
1
  import gradio as gr
2
- from evodiff.pretrained import OA_DM_38M, D3PM_UNIFORM_38M
3
  from evodiff.generate import generate_oaardm, generate_d3pm
 
 
4
 
 
5
 
 
6
 
7
- def make_seq(seq_len, model_type):
8
  if model_type == "EvoDiff-Seq-OADM 38M":
9
  checkpoint = OA_DM_38M()
10
  model, collater, tokenizer, scheme = checkpoint
@@ -17,13 +21,36 @@ def make_seq(seq_len, model_type):
17
 
18
  return generated_sequence
19
 
20
- # iface = gr.Interface(
21
- # fn=make_seq,
22
- # inputs=gr.Slider(10, 100),
23
- # outputs="text"
24
- # )
 
 
25
 
26
- # iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
 
29
  with gr.Blocks() as edapp:
@@ -35,23 +62,13 @@ with gr.Blocks() as edapp:
35
 
36
  Created By: Microsoft Research [Sarah Alamdari, Nitya Thakkar, Rianne van den Berg, Alex X. Lu, Nicolo Fusi, ProfileAva P. Amini, and Kevin K. Yang]
37
 
38
- Spaces App By: Colby T. Ford
39
  """
40
  )
41
  with gr.Row():
42
- gr.Markdown(
43
- """
44
- ## Unconditional sequence generation
45
- Generate a sequence with `EvoDiff-Seq-OADM 38M` (smaller) or `EvoDiff-D3PM-Uniform 38M` (larger) models.
46
- """)
47
- gr.Interface(
48
- fn=make_seq,
49
- inputs=[
50
- gr.Slider(10, 100, label = "Sequence Length"),
51
- gr.Dropdown(["EvoDiff-Seq-OADM 38M", "EvoDiff-D3PM-Uniform 38M"], type="value", label = "Model")
52
- ],
53
- outputs="text"
54
- )
55
 
56
  if __name__ == "__main__":
57
  edapp.launch()
 
1
  import gradio as gr
2
+ from evodiff.pretrained import OA_DM_38M, D3PM_UNIFORM_38M, MSA_OA_DM_MAXSUB
3
  from evodiff.generate import generate_oaardm, generate_d3pm
4
+ from evodiff.generate_msa import generate_query_oadm_msa_simple
5
+ import re
6
 
7
+ def a3m_file(file):
8
 
9
+ return "tmp.a3m"
10
 
11
+ def make_uncond_seq(seq_len, model_type):
12
  if model_type == "EvoDiff-Seq-OADM 38M":
13
  checkpoint = OA_DM_38M()
14
  model, collater, tokenizer, scheme = checkpoint
 
21
 
22
  return generated_sequence
23
 
24
+ def make_cond_seq(seq_len, msa_file, model_type):
25
+ if model_type == "EvoDiff-MSA":
26
+ checkpoint = MSA_OA_DM_MAXSUB()
27
+ model, collater, tokenizer, scheme = checkpoint
28
+ tokeinzed_sample, generated_sequence = generate_query_oadm_msa_simple(msa_file, model, tokenizer, n_sequences=64, seq_length=seq_len, device='cpu', selection_type='random')
29
+
30
+ return generated_sequence
31
 
32
+ usg_app = gr.Interface(
33
+ fn=make_uncond_seq,
34
+ inputs=[
35
+ gr.Slider(10, 100, label = "Sequence Length"),
36
+ gr.Dropdown(["EvoDiff-Seq-OADM 38M", "EvoDiff-D3PM-Uniform 38M"], type="value", label = "Model")
37
+ ],
38
+ outputs="text",
39
+ title = "Unconditional sequence generation",
40
+ description="Generate a sequence with `EvoDiff-Seq-OADM 38M` (smaller/faster) or `EvoDiff-D3PM-Uniform 38M` (larger/slower) models."
41
+ )
42
+
43
+ csg_app = gr.Interface(
44
+ fn=make_cond_seq,
45
+ inputs=[
46
+ gr.Slider(10, 100, label = "Sequence Length"),
47
+ gr.File(file_types=["a3m"], label = "MSA File"),
48
+ gr.Dropdown(["EvoDiff-MSA"], type="value", label = "Model")
49
+ ],
50
+ outputs="text",
51
+ title = "Conditional sequence generation",
52
+ description="Evolutionary guided sequence generation with the `EvoDiff-MSA` model."
53
+ )
54
 
55
 
56
  with gr.Blocks() as edapp:
 
62
 
63
  Created By: Microsoft Research [Sarah Alamdari, Nitya Thakkar, Rianne van den Berg, Alex X. Lu, Nicolo Fusi, ProfileAva P. Amini, and Kevin K. Yang]
64
 
65
+ Spaces App By: [Colby T. Ford](httos://github.com/colbyford)
66
  """
67
  )
68
  with gr.Row():
69
+ gr.TabbedInterface([usg_app, csg_app], ["Unconditional sequence generation", "Conditional generation"])
70
+
71
+
 
 
 
 
 
 
 
 
 
 
72
 
73
  if __name__ == "__main__":
74
  edapp.launch()