TianlaiChen commited on
Commit
f560239
1 Parent(s): 49709b2
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -3,14 +3,14 @@ from transformers import AutoTokenizer, AutoModelForMaskedLM
3
  import torch
4
  from torch.distributions.categorical import Categorical
5
 
6
- '''
7
  # Load the model and tokenizer
8
  tokenizer = AutoTokenizer.from_pretrained("TianlaiChen/PepMLM-650M")
9
  model = AutoModelForMaskedLM.from_pretrained("TianlaiChen/PepMLM-650M")
10
 
11
 
12
  def generate_peptide(protein_seq, peptide_length, top_k):
13
- print('Within')
14
  peptide_length = int(peptide_length)
15
  top_k = int(top_k)
16
 
@@ -31,19 +31,18 @@ def generate_peptide(protein_seq, peptide_length, top_k):
31
 
32
  generated_peptide = tokenizer.decode(predicted_token_ids, skip_special_tokens=True)
33
  return f"Generated Sequence: {generated_peptide.replace(' ', '')}"
34
- '''
35
 
36
- def hello():
37
- print('hello')
38
- return "hello"
39
 
40
  # Define the Gradio interface
41
  interface = gr.Interface(
42
- fn=hello,
43
  inputs=[
44
- gr.Textbox(label="Protein Sequence", default="Enter protein sequence here", type="text"),
45
- gr.Dropdown(choices=[str(i) for i in range(2, 51)], label="Peptide Length", default="15"),
46
- gr.Dropdown(choices=[str(i) for i in range(1, 11)], label="Top K Value", default="3")
 
 
47
  ],
48
  outputs="textbox",
49
  )
 
3
  import torch
4
  from torch.distributions.categorical import Categorical
5
 
6
+
7
  # Load the model and tokenizer
8
  tokenizer = AutoTokenizer.from_pretrained("TianlaiChen/PepMLM-650M")
9
  model = AutoModelForMaskedLM.from_pretrained("TianlaiChen/PepMLM-650M")
10
 
11
 
12
  def generate_peptide(protein_seq, peptide_length, top_k):
13
+
14
  peptide_length = int(peptide_length)
15
  top_k = int(top_k)
16
 
 
31
 
32
  generated_peptide = tokenizer.decode(predicted_token_ids, skip_special_tokens=True)
33
  return f"Generated Sequence: {generated_peptide.replace(' ', '')}"
 
34
 
35
+
 
 
36
 
37
  # Define the Gradio interface
38
  interface = gr.Interface(
39
+ fn=generate_peptide,
40
  inputs=[
41
+ gr.Textbox(label="Protein Sequence", info = "Enter protein sequence here", type="text"),
42
+ gr.Dropdown(choices=[str(i) for i in range(2, 51)], label="Peptide Length", default="15",
43
+ info='Default value is 15'),
44
+ gr.Dropdown(choices=[str(i) for i in range(1, 11)], label="Top K Value", default="3",
45
+ info='Default value is 3')
46
  ],
47
  outputs="textbox",
48
  )