Spaces:
Sleeping
Sleeping
kenbaker-gif
commited on
Commit
·
4847078
1
Parent(s):
3580d9f
Update app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#%%writefile app.py
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
# Load Hugging Face spam classifier
|
| 7 |
+
classifier = pipeline("text-classification", model="kenbaker-gif/Email_Spam_Classifier")
|
| 8 |
+
|
| 9 |
+
# Prediction function
|
| 10 |
+
def predict_spam(text):
|
| 11 |
+
result = classifier(text)[0]
|
| 12 |
+
return f"Label: {result['label']}, Score: {result['score']:.2f}"
|
| 13 |
+
|
| 14 |
+
# Create Gradio interface
|
| 15 |
+
demo = gr.Interface(
|
| 16 |
+
fn=predict_spam,
|
| 17 |
+
inputs="text",
|
| 18 |
+
outputs="text",
|
| 19 |
+
title="Spam Classifier",
|
| 20 |
+
description="Type an email to see if it's spam."
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
# Launch (gives shareable link)
|
| 24 |
+
demo.launch()
|