Spaces:
Sleeping
Sleeping
Update app_gradio.py
Browse files- app_gradio.py +26 -26
app_gradio.py
CHANGED
@@ -1,27 +1,27 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from utils import model_predict
|
3 |
-
|
4 |
-
def predict_spam(text):
|
5 |
-
prediction = model_predict(text)
|
6 |
-
if prediction == 1:
|
7 |
-
return "🚫 This is SPAM!"
|
8 |
-
else:
|
9 |
-
return "✅ This is NOT spam"
|
10 |
-
|
11 |
-
# Create Gradio interface
|
12 |
-
demo = gr.Interface(
|
13 |
-
fn=predict_spam,
|
14 |
-
inputs=gr.Textbox(label="Enter email text", lines=4, placeholder="Type or paste email text here..."),
|
15 |
-
outputs=gr.Textbox(label="Prediction"),
|
16 |
-
title="Email Spam Detector",
|
17 |
-
description="Enter an email text to check if it's spam or not.",
|
18 |
-
examples=[
|
19 |
-
["CONGRATULATIONS! You've won $1,000,000 in our lottery! Click here to claim your prize now!"],
|
20 |
-
["Hi Sarah, Just following up on the project timeline we discussed yesterday. Could you send me the updated schedule?"],
|
21 |
-
["Buy now! 90% OFF luxury watches. Authentic Rolex, Omega, TAG. Limited stock!"],
|
22 |
-
["Dear Mr. Thompson, Thank you for your recent purchase. Your order #12345 has been shipped."]
|
23 |
-
]
|
24 |
-
)
|
25 |
-
|
26 |
-
if __name__ == "__main__":
|
27 |
demo.launch()
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from utils import model_predict
|
3 |
+
|
4 |
+
def predict_spam(text):
|
5 |
+
prediction = model_predict(text)
|
6 |
+
if prediction == 1:
|
7 |
+
return "🚫 This is SPAM!"
|
8 |
+
else:
|
9 |
+
return "✅ This is NOT spam"
|
10 |
+
|
11 |
+
# Create Gradio interface
|
12 |
+
demo = gr.Interface(
|
13 |
+
fn=predict_spam,
|
14 |
+
inputs=gr.Textbox(label="Enter email text", lines=4, placeholder="Type or paste email text here..."),
|
15 |
+
outputs=gr.Textbox(label="Prediction"),
|
16 |
+
title="Yahya Benmahane | Email Spam Detector",
|
17 |
+
description="Enter an email text to check if it's spam or not.",
|
18 |
+
examples=[
|
19 |
+
["CONGRATULATIONS! You've won $1,000,000 in our lottery! Click here to claim your prize now!"],
|
20 |
+
["Hi Sarah, Just following up on the project timeline we discussed yesterday. Could you send me the updated schedule?"],
|
21 |
+
["Buy now! 90% OFF luxury watches. Authentic Rolex, Omega, TAG. Limited stock!"],
|
22 |
+
["Dear Mr. Thompson, Thank you for your recent purchase. Your order #12345 has been shipped."]
|
23 |
+
]
|
24 |
+
)
|
25 |
+
|
26 |
+
if __name__ == "__main__":
|
27 |
demo.launch()
|