File size: 2,549 Bytes
3ece550 924d303 3ece550 1a3ded7 ff35429 1a3ded7 ff35429 3ece550 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
import gradio as gr
from app.handler import predict
markdown_doc_fr = """
# 📘 Documentation du modèle ToxiCheck
Ce modèle détecte automatiquement la toxicité des commentaires en français à l’aide de variantes de CamemBERT.
---
### 📊 Performances
- Précision (non toxique) : 0.93
- Rappel (non toxique) : 0.93
- F1-score (non toxique) : 0.93
- Précision (toxique) : 0.62
- Rappel (toxique) : 0.61
- F1-score (toxique) : 0.61
- Accuracy globale : 0.88
---
### ⚙️ Types de modèles disponibles
- `zero-shot` : modèle générique sans entraînement spécifique
- `few-shot` : modèle avec apprentissage partiel
- `fine-tuned` : modèle CamemBERT entraîné sur un corpus annoté
---
### 🔗 Modèle utilisé
[ymokay/toxicheck-camembert](https://huggingface.co/ymokay/toxicheck-camembert)
"""
markdown_doc_en = """
# 📘 ToxiCheck Model Documentation
This model automatically detects toxic comments in French using variants of CamemBERT.
---
### 📊 Performance
- Precision (non-toxic): 0.93
- Recall (non-toxic): 0.93
- F1-score (non-toxic): 0.93
- Precision (toxic): 0.62
- Recall (toxic): 0.61
- F1-score (toxic): 0.61
- Overall accuracy: 0.88
---
### ⚙️ Available model types
- `zero-shot`: general-purpose model without specific training
- `few-shot`: model trained on a few examples
- `fine-tuned`: CamemBERT model trained on an annotated corpus
---
### 🔗 Model used
[ymokay/toxicheck-camembert](https://huggingface.co/ymokay/toxicheck-camembert)
"""
def create_interface():
with gr.Blocks() as demo:
with gr.Tabs():
with gr.TabItem("📘 Documentation"):
lang_selector = gr.Radio(["fr", "en"], label="Langue / Language", value="fr")
doc_output = gr.Markdown()
def show_doc(lang):
return markdown_doc_fr if lang == "fr" else markdown_doc_en
lang_selector.change(fn=show_doc, inputs=lang_selector, outputs=doc_output)
with gr.TabItem("🧪 Inférence"):
gr.Markdown("### Analyse d'un texte")
input_text = gr.Textbox(label="Texte à analyser")
model_choice = gr.Dropdown(choices=["zero-shot", "few-shot", "fine-tuned"], label="Type de modèle", value="zero-shot")
output = gr.Markdown()
button = gr.Button("Analyser")
button.click(fn=predict, inputs=[input_text, model_choice], outputs=output)
return demo
def launch_app():
iface = create_interface()
iface.launch() |