dev_NLP / app.py
ahmadouna's picture
Update app.py
b787b27
raw
history blame
840 Bytes
import streamlit as st
from transformers import pipeline
# Initialisation de la pipeline de classification à zéro tir
classifier = pipeline("zero-shot-classification", model="morit/french_xlm_xnli")
# Création d'une entrée pour le texte à analyser
text = st.text_input('Entrer le texte à analyser')
# Labels candidats pour la classification
candidate_labels = ["commentaire positive", "commentaire négative"]
# Modèle de phrase pour la formation de l'hypothèse
hypothesis_template = "Cet exemple est un {}."
# Exécution de la classification seulement si du texte est entré
if text and candidate_labels: # Vérifier si du texte et au moins une étiquette sont présents
st.write(classifier(text, candidate_labels, hypothesis_template=hypothesis_template))
else:
st.write("Veuillez entrer du texte pour l'analyse.")