sihuapeng commited on
Commit
cbd5ac0
·
verified ·
1 Parent(s): 4d4c785

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +7 -5
README.md CHANGED
@@ -36,11 +36,11 @@ from transformers import AutoTokenizer, AutoModelForSequenceClassification
36
  import torch
37
 
38
  # Load the fine-tuned model and tokenizer
39
- model_name = "sihuapeng/ESM2-finetuned-PPSL"
40
  tokenizer = AutoTokenizer.from_pretrained(model_name)
41
  model = AutoModelForSequenceClassification.from_pretrained(model_name)
42
 
43
- # Protein sequence for prediction the subcelluar localization
44
  protein_sequence = "MSKKVLITGGAGYIGSVLTPILLEKGYEVCVIDNLMFDQISLLSCFHNKNFTFINGDAMDENLIRQEVAKADIIIPLAALVGAPLCKRNPKLAKMINYEAVKMISDFASPSQIFIYPNTNSGYGIGEKDAMCTEESPLRPISEYGIDKVHAEQYLLDKGNCVTFRLATVFGISPRMRLDLLVNDFTYRAYRDKFIVLFEEHFRRNYIHVRDVVKGFIHGIENYDKMKGQAYNMGLSSANLTKRQLAETIKKYIPDFYIHSANIGEDPDKRDYLVSNTKLEATGWKPDNTLEDGIKELLRAFKMMKVNRFANFN"
45
 
46
  # Encode the sequence as model input
@@ -50,15 +50,17 @@ inputs = tokenizer(protein_sequence, return_tensors="pt")
50
  with torch.no_grad():
51
  outputs = model(**inputs)
52
 
53
- # Get the prediction results
54
  logits = outputs.logits
55
  predicted_class_id = torch.argmax(logits, dim=-1).item()
 
 
56
 
57
  # Output the predicted class
58
  print ("===========================================================================================================================================")
59
- print ("ID to Label mapping: {0: 'CYtoplasmicMembrane', 1: 'Cellwall', 2: 'Cytoplasmic', 3: 'Extracellular', 4: 'OuterMembrane', 5: 'Periplasmic'}")
60
- print(f"Predicted class ID: {predicted_class_id}")
61
  print ("===========================================================================================================================================")
 
62
  ```
63
 
64
  ## Funding
 
36
  import torch
37
 
38
  # Load the fine-tuned model and tokenizer
39
+ model_name = "sihuapeng/PPPSL-ESM2"
40
  tokenizer = AutoTokenizer.from_pretrained(model_name)
41
  model = AutoModelForSequenceClassification.from_pretrained(model_name)
42
 
43
+ # Sample protein sequence
44
  protein_sequence = "MSKKVLITGGAGYIGSVLTPILLEKGYEVCVIDNLMFDQISLLSCFHNKNFTFINGDAMDENLIRQEVAKADIIIPLAALVGAPLCKRNPKLAKMINYEAVKMISDFASPSQIFIYPNTNSGYGIGEKDAMCTEESPLRPISEYGIDKVHAEQYLLDKGNCVTFRLATVFGISPRMRLDLLVNDFTYRAYRDKFIVLFEEHFRRNYIHVRDVVKGFIHGIENYDKMKGQAYNMGLSSANLTKRQLAETIKKYIPDFYIHSANIGEDPDKRDYLVSNTKLEATGWKPDNTLEDGIKELLRAFKMMKVNRFANFN"
45
 
46
  # Encode the sequence as model input
 
50
  with torch.no_grad():
51
  outputs = model(**inputs)
52
 
53
+ # Get the prediction result
54
  logits = outputs.logits
55
  predicted_class_id = torch.argmax(logits, dim=-1).item()
56
+ id2label = {0: 'CYtoplasmicMembrane', 1: 'Cellwall', 2: 'Cytoplasmic', 3: 'Extracellular', 4: 'OuterMembrane', 5: 'Periplasmic'}
57
+ predicted_label = id2label[predicted_class_id]
58
 
59
  # Output the predicted class
60
  print ("===========================================================================================================================================")
61
+ print(f"Predicted class Label: {predicted_label}")
 
62
  print ("===========================================================================================================================================")
63
+
64
  ```
65
 
66
  ## Funding