File size: 402 Bytes
c85a31e
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from transformers import pipeline
import gradio as gr

# Chargement du pipeline d'analyse de sentiment
sentiment = pipeline("sentiment-analysis")

# Fonction pour prédire le sentiment
def predict(review):
    result = sentiment(review)[0]
    return f"Sentiment : {result['label']}, confiance {result['score']:.2f}"

# Interface Gradio
gr.Interface(fn=predict, inputs="text", outputs="text").launch()