File size: 1,179 Bytes
84c61fb
 
 
 
 
 
aa8e598
84c61fb
 
 
 
 
aa8e598
 
 
 
 
 
 
 
a436929
aa8e598
 
 
 
 
 
 
171e852
b1eca6f
171e852
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
from transformers import AutoModelForSequenceClassification, AutoTokenizer

model = AutoModelForSequenceClassification.from_pretrained("inkleaves/spam_detection_model")
tokenizer = AutoTokenizer.from_pretrained("inkleaves/spam_detection_model")

def predict_spam(text):
    inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
    outputs = model(**inputs)
    prediction = outputs.logits.argmax(dim=-1).item()
    return "Spam" if prediction == 1 else "Not Spam"

# interface = gr.Interface(fn=predict, inputs="text", outputs="text")
#interface.launch(share=True)

# Create the Gradio interface
app = gr.Interface(
    fn=predict_spam, 
    inputs="text", 
    outputs="text", 
    live=False,
    title="Spam Detection",  # Title of the app
    description="This app classifies text as either Spam or Ham.",  # Description of the app
)

# Add a custom header in larger, bolded text using HTML
header = gr.HTML("<h1 style='font-size:36px; font-weight:bold;'>Spam Detection App</h1>")

# Launch the app with the header displayed above the interface
#header.launch(share=True)  # Launching header
app.launch(share=True)  # Launching app