Abso1ute666 commited on
Commit
0888aa2
1 Parent(s): 7d42514

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
3
+ import torch
4
+
5
+ title = "Protien Sequence Classification 🧬."
6
+ description = "Predicts the subcellular location of the protein sequence between two classes: Cytoplasm and Membrane"
7
+ article = 'Created from finetuning ESM2_150M'
8
+
9
+ model = AutoModelForSequenceClassification.from_pretrained('./Model')
10
+ tokenizer = AutoTokenizer.from_pretrained('facebook/esm2_t30_150M_UR50D')
11
+
12
+ example_list = [['MKIIILLGFLGATLSAPLIPQRLMSASNSNELLLNLNNGQLLPLQLQGPLNSWIPPFSGILQQQQQAQIPGLSQFSLSALDQFAGLLPNQIPLTGEASFAQGAQAGQVDPLQLQTPPQTQPGPSHVMPYVFSFKMPQEQGQMFQYYPVYMVLPWEQPQQTVPRSPQQTRQQQYEEQIPFYAQFGYIPQLAEPAISGGQQQLAFDPQLGTAPEIAVMSTGEEIPYLQKEAINFRHDSAGVFMPSTSPKPSTTNVFTSAVDQTITPELPEEKDKTDSLREP'],
13
+ ['MSSGNYQQSEALSKPTFSEEQASALVESVFGLKVSKVRPLPSYDDQNFHVYVSKTKDGPTEYVLKISNTKASKNPDLIEVQNHIIMFLKAAGFPTASVCHTKGDNTASLVSVDSGSEIKSYLVRLLTYLPGRPIAELPVSPQLLYEIGKLAAKLDKTLQRFHHPKLSSLHRENFIWNLKNVPLLEKYLYALGQNRNREIVEHVIHLFKEEVMTKLSHFRECINHGDLNDHNILIESSKSASGNAEYQVSGILDFGDMSYGYYVFEVAITIMYMMIESKSPIQVGGHVLAGFESITPLTAVEKGALFLLVCSRFCQSLVMAAYSCQLYPENKDYLMVTAKTGWKHLQQMFDMGQKAVEEIWFETAKSYESGISM'],
14
+ ['MMNNTDFLMLNNPWNKLCLVSMDFCFPLDFVSNLFWIFASKFIIVTGQIKADFKRTSWEAKAEGSLEPGRLKLQLASIVPLYSSLVTAGPASKIIILKRTSLPTVSPSNERAYLLPVSFTDLAHVFYLSYFSINAKSNSFSLDIIIALGIPHNTQAHFNH'],
15
+ ['MNKHNLRLVQLASELILIEIIPKLFLSQVTTISHIKREKIPPNHRKGILCMFPWQCVVYVFSNFVWLVIHRFSNGFIQFLGEPYRLMTASGTHGRIKFMVDIPIIKNTQVLRIPVLKDPKMLSKKH']]
16
+
17
+ def predict(ProtienSequence):
18
+ input = tokenizer(ProtienSequence, return_tensors='pt')
19
+ with torch.inference_mode():
20
+ outputs = model(**input)
21
+ output = outputs.logits.argmax(axis=1)[0].numpy() == 0
22
+ print(output)
23
+ if output:
24
+ return str('Cytoplasm')
25
+ else:
26
+ return str('Membrane')
27
+
28
+ iface = gr.Interface(fn=predict,
29
+ inputs='text',
30
+ outputs=gr.Text(label='Subcellular location'),
31
+ title=title,
32
+ description=description,
33
+ article=article,
34
+ examples=example_list)
35
+ iface.launch()