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