Spaces:
Sleeping
Sleeping
Fryxis
commited on
Commit
·
14aa24c
1
Parent(s):
4b82bbc
ajout des documents
Browse files- app.py +27 -0
- requirements.txt +6 -0
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
# Chargement du modèle
|
5 |
+
classifier = pipeline(
|
6 |
+
"sentiment-analysis",
|
7 |
+
model="mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis"
|
8 |
+
)
|
9 |
+
|
10 |
+
# Fonction d'analyse
|
11 |
+
def analyze_sentiment(text):
|
12 |
+
if not text:
|
13 |
+
return "Entrez une phrase."
|
14 |
+
result = classifier(text)[0]
|
15 |
+
return f"Sentiment : {result['label']} (Score: {result['score']:.2f})"
|
16 |
+
|
17 |
+
# Interface utilisateur
|
18 |
+
iface = gr.Interface(
|
19 |
+
fn=analyze_sentiment,
|
20 |
+
inputs=gr.Textbox(lines=2, placeholder="Entrez une actualité financière ici..."),
|
21 |
+
outputs="text",
|
22 |
+
title="Analyse de Sentiment Financier 📈",
|
23 |
+
description="Entrez une news financière pour analyser automatiquement le sentiment positif, neutre ou négatif."
|
24 |
+
)
|
25 |
+
|
26 |
+
# Lancement local de l'application
|
27 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
torch
|
3 |
+
gradio
|
4 |
+
datasets
|
5 |
+
tokenizers
|
6 |
+
gradio
|