greykingreys commited on
Commit
27f56db
·
verified ·
1 Parent(s): aac459e

Upload 5 files

Browse files
Files changed (5) hide show
  1. app.py +29 -0
  2. encoder.joblib +3 -0
  3. nb.joblib +3 -0
  4. requirements.txt +6 -0
  5. vectorizer.joblib +3 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import numpy as np
4
+ import joblib
5
+ from deep_translator import GoogleTranslator
6
+
7
+ model = joblib.load('nb.joblib')
8
+ vectorizer = joblib.load('vectorizer.joblib')
9
+ encoder = joblib.load('encoder.joblib')
10
+
11
+ def pred(message):
12
+ message = GoogleTranslator(source= 'fr', target= 'en').translate(message)
13
+ vecteur = vectorizer.transform([message])
14
+ prediction = model.predict(vecteur)[0]
15
+
16
+ label = f"{'SPAM' if prediction == 1 else 'HAM'}"
17
+ return label
18
+
19
+
20
+ interface = gr.Interface(
21
+ fn = pred,
22
+ inputs= gr.Textbox(lines= 3, placeholder= "Tape ton message"),
23
+ outputs= gr.Textbox(label= "Resultat"),
24
+ title= "Detections des SPAM par IA",
25
+ description= "Entrez un message et l'application vous dira s'il s'agit de SPAM ou de HAM"
26
+ )
27
+
28
+ if __name__ == "__main__":
29
+ interface.launch()
encoder.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b44297fc24d57000e643dff5109674479501e7c15882812f9d6bbd6c64a1289c
3
+ size 486
nb.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:98085f55ef2aa7d0071071d1e5aec7d9ce59110293680630bae4add3b6ce73e9
3
+ size 160791
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ pandas
2
+ numpy
3
+ joblib
4
+ gradio
5
+ scikit-learn
6
+ deep-translator
vectorizer.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0bd431c969880871c453035053619d61ee58f3d85f141e807601d2d91c891fa
3
+ size 179834