Spaces:
Runtime error
Runtime error
| # script to load the model and make prediction | |
| import joblib | |
| import numpy as np | |
| import gradio as gr | |
| model = joblib.load("lang_detect_model.joblib") | |
| def detect_lang(text: str) -> str: | |
| pred = model.predict([text]) | |
| # pred_prob = model.predict_proba([text]) | |
| # pred_prob = round(np.max(pred_prob) * 100, 2) | |
| lang_dict = { | |
| 'ar': 'Arabic', | |
| 'de': 'Deutsch', | |
| 'en': 'English', | |
| 'es': 'Spanish', | |
| 'fr': 'France', | |
| 'it': 'Italy', | |
| 'ja': 'Japanese', | |
| 'nl': 'Dutch', | |
| 'pl': 'Polish', | |
| 'pt': 'Portuguese', | |
| 'ru': 'Russian' | |
| } | |
| lang_name = lang_dict[pred[0]] | |
| return lang_name | |
| iface = gr.Interface( | |
| detect_lang, | |
| "text", | |
| "text" | |
| ) | |
| iface.launch() | |