deniandriancode commited on
Commit
2c824f6
·
1 Parent(s): 35d1ad0

add app.py

Browse files
Files changed (3) hide show
  1. app.py +34 -0
  2. lang_detect_model.joblib +3 -0
  3. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # script to load the model and make prediction
2
+ import joblib
3
+ import numpy as np
4
+ import gradio as gr
5
+
6
+ model = joblib.load("lang_detect_model.joblib")
7
+
8
+ def detect_lang(text: str) -> str:
9
+ pred = model.predict([text])
10
+ # pred_prob = model.predict_proba([text])
11
+ # pred_prob = round(np.max(pred_prob) * 100, 2)
12
+ lang_dict = {
13
+ 'ar': 'Arabic',
14
+ 'de': 'Deutsch',
15
+ 'en': 'English',
16
+ 'es': 'Spanish',
17
+ 'fr': 'France',
18
+ 'it': 'Italy',
19
+ 'ja': 'Japanese',
20
+ 'nl': 'Dutch',
21
+ 'pl': 'Polish',
22
+ 'pt': 'Portuguese',
23
+ 'ru': 'Russian'
24
+ }
25
+ lang_name = lang_dict[pred[0]]
26
+ return lang_name
27
+
28
+
29
+ iface = gr.Interface(
30
+ detect_lang,
31
+ "text",
32
+ "text"
33
+ )
34
+ iface.launch()
lang_detect_model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5b3fe6d5d4246c6cb791902d215aa097f9446617c4eed93f3c278c354b101c79
3
+ size 218514
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ scikit-learn