Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,11 +4,28 @@ from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
|
4 |
model = AutoModelForSequenceClassification.from_pretrained("inkleaves/spam_detection_model")
|
5 |
tokenizer = AutoTokenizer.from_pretrained("inkleaves/spam_detection_model")
|
6 |
|
7 |
-
def
|
8 |
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
|
9 |
outputs = model(**inputs)
|
10 |
prediction = outputs.logits.argmax(dim=-1).item()
|
11 |
return "Spam" if prediction == 1 else "Not Spam"
|
12 |
|
13 |
-
interface = gr.Interface(fn=predict, inputs="text", outputs="text")
|
14 |
-
interface.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
model = AutoModelForSequenceClassification.from_pretrained("inkleaves/spam_detection_model")
|
5 |
tokenizer = AutoTokenizer.from_pretrained("inkleaves/spam_detection_model")
|
6 |
|
7 |
+
def predict_spam(text):
|
8 |
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
|
9 |
outputs = model(**inputs)
|
10 |
prediction = outputs.logits.argmax(dim=-1).item()
|
11 |
return "Spam" if prediction == 1 else "Not Spam"
|
12 |
|
13 |
+
# interface = gr.Interface(fn=predict, inputs="text", outputs="text")
|
14 |
+
#interface.launch(share=True)
|
15 |
+
|
16 |
+
# Create the Gradio interface
|
17 |
+
app = gr.Interface(
|
18 |
+
fn=predict_spam,
|
19 |
+
inputs="text",
|
20 |
+
outputs="text",
|
21 |
+
live=True,
|
22 |
+
title="Spam Detection", # Title of the app
|
23 |
+
description="This app classifies text as either Spam or Ham.", # Description of the app
|
24 |
+
theme="huggingface" # Optional: use a predefined theme
|
25 |
+
)
|
26 |
+
|
27 |
+
# Add a custom header in larger, bolded text using HTML
|
28 |
+
header = gr.HTML("<h1 style='font-size:36px; font-weight:bold;'>Spam Detection App</h1>")
|
29 |
+
|
30 |
+
# Combine header and interface in a layout
|
31 |
+
gr.Blocks().add(header, app).launch(share=True)
|