Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
3 |
+
|
4 |
+
model = AutoModelForSequenceClassification.from_pretrained("inkleaves/spam_detection_model")
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained("inkleaves/spam_detection_model")
|
6 |
+
|
7 |
+
def predict(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()
|