Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
import fasttext
|
|
|
|
|
3 |
|
4 |
-
#
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Fonction de prédiction de la langue
|
8 |
def predict_language(text):
|
|
|
1 |
import gradio as gr
|
2 |
import fasttext
|
3 |
+
import os
|
4 |
+
from huggingface_hub import hf_hub_download
|
5 |
|
6 |
+
# Téléchargement du modèle depuis Hugging Face
|
7 |
+
model_path = hf_hub_download(repo_id="facebook/fasttext-language-identification", filename="lid.176.bin")
|
8 |
+
|
9 |
+
# Vérifier si le modèle a bien été téléchargé
|
10 |
+
if not os.path.exists(model_path):
|
11 |
+
raise ValueError(f"Le modèle {model_path} n'a pas pu être téléchargé!")
|
12 |
+
|
13 |
+
# Charger le modèle avec FastText
|
14 |
+
model = fasttext.load_model(model_path)
|
15 |
|
16 |
# Fonction de prédiction de la langue
|
17 |
def predict_language(text):
|