Upload Model.py
Browse files
Model.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
# coding: utf-8
|
| 3 |
+
|
| 4 |
+
# In[10]:
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
import gradio as gr
|
| 8 |
+
from joblib import load
|
| 9 |
+
|
| 10 |
+
model = load('model.joblib')
|
| 11 |
+
conv = load('tfd.joblib')
|
| 12 |
+
|
| 13 |
+
def prediction(email):
|
| 14 |
+
|
| 15 |
+
inp = [email]
|
| 16 |
+
|
| 17 |
+
inp_final = conv.transform(inp)
|
| 18 |
+
|
| 19 |
+
res = model.predict(inp_final)[0]
|
| 20 |
+
|
| 21 |
+
return "not spam" if res == 1 else 'spam'
|
| 22 |
+
|
| 23 |
+
iface = gr.Interface(
|
| 24 |
+
|
| 25 |
+
fn = prediction,
|
| 26 |
+
inputs = [gr.Text(label="Email")],
|
| 27 |
+
outputs = 'text',
|
| 28 |
+
title = 'spam Identifier',
|
| 29 |
+
description = 'spam detection')
|
| 30 |
+
|
| 31 |
+
iface.launch()
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
# In[9]:
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
# In[ ]:
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
|