Spaces:
Sleeping
Sleeping
# import pandas as pd | |
# import streamlit as st | |
# from transformers import pipeline | |
# from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, balanced_accuracy_score | |
# # Charger le modèle pré-entraîné | |
# classifier_model = "morit/french_xlm_xnli" | |
import pandas as pd | |
import streamlit as st | |
from transformers import pipeline | |
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, balanced_accuracy_score | |
# Charger le modèle pré-entraîné | |
classifier_model = "MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli" | |
classifier = pipeline("zero-shot-classification", model=classifier_model) | |
# Afficher l'entête | |
st.header("Sentiment Analysis") | |
df = pd.read_csv("fic.csv", sep=";") | |
# Récupérer les commentaires en liste | |
comments = df["text"].tolist() | |
# Afficher l'entête | |
st.header("Text Analysis") | |
# Créer une selectbox pour choisir un commentaire | |
selected_comment = st.selectbox("Choose comments or type text", comments) | |
# Afficher le commentaire sélectionné dans l'input text | |
text = st.text_area('Text zone', value=selected_comment) | |
# Labels candidats pour la classification | |
candidate_labels = [1, 0] | |
# Modèle de phrase pour la formation de l'hypothèse | |
hypothesis_template = "This example is a {}." | |
# Ajouter un bouton pour déclencher l'analyse | |
if st.button("Analyser le texte"): | |
if text and candidate_labels: | |
result = classifier(text, candidate_labels, hypothesis_template=hypothesis_template) | |
if result['labels'][0] == 1: | |
st.info(f"Résults Good comments ,accuracy {result['scores'][0]*100:.2f}%") | |
if result['labels'][0] == 0: | |
st.info(f" Bad comments,accuracy= {result['scores'][0]*100:.2f}%") | |
else: | |
st.write("Text Analysis.") |