benjika commited on
Commit
38b5da8
·
verified ·
1 Parent(s): 33852dd

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ model_path = "./model"
5
+ classifier = pipeline("text-classification", model="./model")
6
+
7
+ def predict(text):
8
+ result = classifier(text)
9
+ return "Safe Email" if result[0]['label'] == "LABEL_0" else "Spam Email"
10
+
11
+ iface = gr.Interface(
12
+ fn=predict,
13
+ inputs="text",
14
+ outputs="label",
15
+ title="Spam or not",
16
+ description="Enter Email body to classify it as spam or not spam.",
17
+ )
18
+
19
+ iface.launch()