|
|
import gradio as gr |
|
|
from transformers import pipeline |
|
|
|
|
|
clf = pipeline("text-classification", model="jeromex1/NorBERT_Chti") |
|
|
|
|
|
def predict(text): |
|
|
result = clf(text)[0] |
|
|
label = result["label"] |
|
|
score = round(result["score"], 3) |
|
|
return f"{label} ({score})" |
|
|
|
|
|
demo = gr.Interface( |
|
|
fn=predict, |
|
|
inputs=gr.Textbox(lines=2, placeholder="Écris une phrase en Chti..."), |
|
|
outputs="text", |
|
|
title="NorBERT – Analyse de sentiments en Chti", |
|
|
description="Fine-tuning de CamemBERT pour la classification (positif / neutre / négatif)." |
|
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
demo.launch() |
|
|
|