Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,18 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
# Charge ton modèle NorBERT depuis le hub
|
| 5 |
clf = pipeline("text-classification", model="jeromex1/NorBERT_Chti")
|
| 6 |
|
| 7 |
def predict(text):
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
# Interface utilisateur web
|
| 11 |
demo = gr.Interface(
|
| 12 |
fn=predict,
|
| 13 |
inputs=gr.Textbox(lines=2, placeholder="Écris une phrase en Chti..."),
|
| 14 |
-
outputs="
|
| 15 |
title="NorBERT – Analyse de sentiments en Chti",
|
| 16 |
description="Fine-tuning de CamemBERT pour la classification (positif / neutre / négatif)."
|
| 17 |
)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
|
|
|
| 4 |
clf = pipeline("text-classification", model="jeromex1/NorBERT_Chti")
|
| 5 |
|
| 6 |
def predict(text):
|
| 7 |
+
result = clf(text)[0] # premier élément
|
| 8 |
+
label = result["label"]
|
| 9 |
+
score = round(result["score"], 3)
|
| 10 |
+
return f"{label} ({score})"
|
| 11 |
|
|
|
|
| 12 |
demo = gr.Interface(
|
| 13 |
fn=predict,
|
| 14 |
inputs=gr.Textbox(lines=2, placeholder="Écris une phrase en Chti..."),
|
| 15 |
+
outputs="text",
|
| 16 |
title="NorBERT – Analyse de sentiments en Chti",
|
| 17 |
description="Fine-tuning de CamemBERT pour la classification (positif / neutre / négatif)."
|
| 18 |
)
|