from huggingface_hub import hf_hub_download | |
import fasttext | |
import gradio as gr | |
# Télécharger le modèle depuis Hugging Face | |
model_path = hf_hub_download(repo_id="facebook/fasttext-language-identification", filename="model.bin") | |
# Charger le modèle avec fastText | |
model = fasttext.load_model(model_path) | |
# Fonction de prédiction de la langue | |
def predict_language(text): | |
prediction = model.predict(text) | |
return prediction[0][0] # Retourne la langue prédite | |
# Interface Gradio | |
iface = gr.Interface(fn=predict_language, inputs="text", outputs="text", live=True) | |
if __name__ == "__main__": | |
iface.launch() | |