ahmadouna commited on
Commit
b787b27
1 Parent(s): 9b6f5f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -9
app.py CHANGED
@@ -1,11 +1,20 @@
1
-
2
  import streamlit as st
3
  from transformers import pipeline
4
- classifier = pipeline("zero-shot-classification",
5
- model="morit/french_xlm_xnli")
6
- text = st.text_input('Entrer le texte a analyser')
7
- candidate_labels = ["commentaire positive", "commentaire negative"]
8
- hypothesis_template = "Cet example estb un {}"
9
- if text:
10
-
11
- st.write(classifier(text, candidate_labels, hypothesis_template=hypothesis_template))
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from transformers import pipeline
3
+
4
+ # Initialisation de la pipeline de classification à zéro tir
5
+ classifier = pipeline("zero-shot-classification", model="morit/french_xlm_xnli")
6
+
7
+ # Création d'une entrée pour le texte à analyser
8
+ text = st.text_input('Entrer le texte à analyser')
9
+
10
+ # Labels candidats pour la classification
11
+ candidate_labels = ["commentaire positive", "commentaire négative"]
12
+
13
+ # Modèle de phrase pour la formation de l'hypothèse
14
+ hypothesis_template = "Cet exemple est un {}."
15
+
16
+ # Exécution de la classification seulement si du texte est entré
17
+ if text and candidate_labels: # Vérifier si du texte et au moins une étiquette sont présents
18
+ st.write(classifier(text, candidate_labels, hypothesis_template=hypothesis_template))
19
+ else:
20
+ st.write("Veuillez entrer du texte pour l'analyse.")