Update app.py
Browse files
app.py
CHANGED
|
@@ -20,40 +20,57 @@ def translate_text(text, src_lang, target_lang):
|
|
| 20 |
|
| 21 |
# Créer l'interface Gradio
|
| 22 |
with gr.Blocks() as interface:
|
| 23 |
-
# Titre et description
|
| 24 |
gr.Markdown("""
|
| 25 |
-
<div style="text-align: center;">
|
| 26 |
<h2>Traduction automatique Lingala-Français</h2>
|
| 27 |
<p>Ceci est la version d'essai et nous comptons sur vous pour améliorer les performances du modèle pour notre langue Lingala.</p>
|
| 28 |
-
<p>Oyo e za version ya komeka pe to zo talela bino pôna ko kolisa makoki ya modeli pôna nkota nà biso Lingala.</p>
|
| 29 |
</div>
|
| 30 |
""")
|
| 31 |
|
| 32 |
-
# Création du formulaire centré
|
| 33 |
-
with gr.
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
source_lang = gr.Dropdown(choices=["fr", "li"], label="Langue Source")
|
| 39 |
-
target_lang = gr.Dropdown(choices=["li", "fr"], label="Langue Cible")
|
| 40 |
-
|
| 41 |
-
with gr.Row(variant="panel", align="center"):
|
| 42 |
-
translate_button = gr.Button("Traduire")
|
| 43 |
-
|
| 44 |
-
with gr.Row(variant="panel", align="center"):
|
| 45 |
-
translation_output = gr.Textbox(label="Traduction", placeholder="Le texte traduit s'affichera ici...")
|
| 46 |
-
|
| 47 |
-
# Lancer la traduction avec le bouton
|
| 48 |
translate_button.click(
|
| 49 |
translate_text,
|
| 50 |
inputs=[text_input, source_lang, target_lang],
|
| 51 |
outputs=translation_output
|
| 52 |
)
|
| 53 |
|
| 54 |
-
# Personnalisation CSS pour la boîte et
|
| 55 |
interface.css = """
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
width: 50%;
|
| 58 |
margin: auto;
|
| 59 |
padding: 20px;
|
|
@@ -62,12 +79,6 @@ interface.css = """
|
|
| 62 |
background-color: #f9f9f9;
|
| 63 |
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
| 64 |
}
|
| 65 |
-
#form-container .row {
|
| 66 |
-
margin-bottom: 15px;
|
| 67 |
-
}
|
| 68 |
-
#form-container .button {
|
| 69 |
-
width: 100%;
|
| 70 |
-
}
|
| 71 |
"""
|
| 72 |
|
| 73 |
# Lancer l'interface
|
|
|
|
| 20 |
|
| 21 |
# Créer l'interface Gradio
|
| 22 |
with gr.Blocks() as interface:
|
| 23 |
+
# Titre et description avec du texte en italique et en gras en lingala
|
| 24 |
gr.Markdown("""
|
| 25 |
+
<div style="text-align: center; font-family: 'Lobster', sans-serif;">
|
| 26 |
<h2>Traduction automatique Lingala-Français</h2>
|
| 27 |
<p>Ceci est la version d'essai et nous comptons sur vous pour améliorer les performances du modèle pour notre langue Lingala.</p>
|
| 28 |
+
<p><strong><em>Oyo e za version ya komeka pe to zo talela bino pôna ko kolisa makoki ya modeli pôna nkota nà biso Lingala.</em></strong></p>
|
| 29 |
</div>
|
| 30 |
""")
|
| 31 |
|
| 32 |
+
# Création du formulaire centré avec une bordure
|
| 33 |
+
with gr.Column(align="center"):
|
| 34 |
+
text_input = gr.Textbox(label="Entrez le texte à traduire", placeholder="Entrez le texte à traduire ici...", lines=3)
|
| 35 |
+
source_lang = gr.Dropdown(choices=["fr", "li"], label="Langue Source")
|
| 36 |
+
target_lang = gr.Dropdown(choices=["li", "fr"], label="Langue Cible")
|
| 37 |
+
translate_button = gr.Button("Traduire")
|
| 38 |
+
translation_output = gr.Textbox(label="Traduction", placeholder="Le texte traduit s'affichera ici...")
|
| 39 |
|
| 40 |
+
# Lier le bouton au processus de traduction
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
translate_button.click(
|
| 42 |
translate_text,
|
| 43 |
inputs=[text_input, source_lang, target_lang],
|
| 44 |
outputs=translation_output
|
| 45 |
)
|
| 46 |
|
| 47 |
+
# Personnalisation CSS pour la boîte et les textes
|
| 48 |
interface.css = """
|
| 49 |
+
/* Police personnalisée pour rendre l'interface plus attrayante */
|
| 50 |
+
@import url('https://fonts.googleapis.com/css2?family=Lobster&display=swap');
|
| 51 |
+
|
| 52 |
+
.gradio-container {
|
| 53 |
+
font-family: 'Arial', sans-serif;
|
| 54 |
+
}
|
| 55 |
+
.gradio-button {
|
| 56 |
+
background-color: #4CAF50;
|
| 57 |
+
color: white;
|
| 58 |
+
border-radius: 5px;
|
| 59 |
+
border: none;
|
| 60 |
+
}
|
| 61 |
+
.gradio-button:hover {
|
| 62 |
+
background-color: #45a049;
|
| 63 |
+
}
|
| 64 |
+
.gr-markdown {
|
| 65 |
+
font-family: 'Lobster', sans-serif;
|
| 66 |
+
font-size: 24px;
|
| 67 |
+
font-weight: bold;
|
| 68 |
+
}
|
| 69 |
+
.gradio-row {
|
| 70 |
+
margin-top: 10px;
|
| 71 |
+
}
|
| 72 |
+
/* Centrer la colonne */
|
| 73 |
+
.gr-column {
|
| 74 |
width: 50%;
|
| 75 |
margin: auto;
|
| 76 |
padding: 20px;
|
|
|
|
| 79 |
background-color: #f9f9f9;
|
| 80 |
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
| 81 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
"""
|
| 83 |
|
| 84 |
# Lancer l'interface
|