Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,20 @@
|
|
| 1 |
-
|
| 2 |
import streamlit as st
|
| 3 |
from transformers import pipeline
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.")
|