inkleaves's picture
Update app.py
8b3132d verified
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