Paulhrd commited on
Commit
4411d6c
1 Parent(s): d4de1ad

import pipeline

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -1,14 +1,22 @@
1
  import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
5
 
6
  demo = gr.Interface(
7
- fn=greet,
8
  inputs="text",
9
  outputs="text",
10
  title="Biology Sequence Classifier",
11
- description="This application determines with a protein sequence given where the localization of this protein sequence comes from",
12
  examples=None,
13
  theme=None,
14
  allow_flagging="never",
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
+ import torch
4
 
5
+ # Chargement du pipeline de classification de texte avec le modèle spécifique
6
+ pipe = pipeline("text-classification", model="Rocketknight1/esm2_t6_8M_UR50D-finetuned-localization")
7
+
8
+ def classify_sequence(sequence):
9
+ result = pipe(sequence)
10
+ # Extraction de la localisation prédite à partir du résultat
11
+ localization = result[0]['label']
12
+ return localization
13
 
14
  demo = gr.Interface(
15
+ fn=classify_sequence,
16
  inputs="text",
17
  outputs="text",
18
  title="Biology Sequence Classifier",
19
+ description="This application determines with a protein sequence given where the localization of this protein sequence comes from. You can try those sequences from each localization:\n'Cell.membrane': 'MGLSDGEWQLVLNVWGKVEADIPGHGQEVLIRLFK',\n'Cytoplasm': 'MDDDIAALVVDNGSGMCKAGFAGDDAPRAVFPSIVG',\n'Endoplasmic.reticulum': 'MKAAVRKVLTVLLLAAAVAGCGNASAEANQNGKPR',\n'Extracellular': 'MGRDGIDTDVFSGPDGKTGQSINNYGGFGADND',\n'Golgi.apparatus': 'MKSVLLLALSLWILPGGQVTQGVDLSSFGNSDLK',\n'Lysosome/Vacuole': 'MKTLLLAILAAWATAEAQTAAPCSGSADAAPTP',\n'Mitochondrion': 'MALWMRLLPLLALLALWGPGPGLSGLALLLAVAP',\n'Nucleus': 'MGLRSGRGKTGGKARAKAKSRSSRAGLQFPVGR',\n'Peroxisome': 'MNLREVRDPLPAHLGRFLRVAAAYRLARFGSD',\n'Plastid': 'MSTIAHRAMVALGEPNAETMGRLEREGAEVRN'",
20
  examples=None,
21
  theme=None,
22
  allow_flagging="never",