alanjoshua2005/Bert-sms-spam-detector-onnx
By alanjoshua2005 · ↓ 0 · ♥ 0 · Updated 2025-09-29
What's in this repo
This page lists the files in alanjoshua2005/Bert-sms-spam-detector-onnx, including bert_sms_detector.onnx.
- 1 ONNX models (.onnx files)
- 7 files, including 3 .json, 1 .md, 1 .onnx, 1 .txt
- Last updated 2025-09-29
ONNX files
| File | Size | Download |
|---|---|---|
| bert_sms_detector.onnx | — | Download |
How to use
These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.
README
Use this model
!pip install transformers numpy onnx onnxruntime -q
import onnxruntime as ort
from transformers import AutoTokenizer
import numpy as np
import requests
onnx_model_url = "https://huggingface.co/alanjoshua2005/Bert-sms-spam-detector-onnx/resolve/main/bert_sms_detector.onnx"
onnx_model_path = "bert_sms_detector.onnx"
with open(onnx_model_path, "wb") as f:
f.write(requests.get(onnx_model_url).content)
# Load tokenizer from the correct repository
tokenizer = AutoTokenizer.from_pretrained("alanjoshua2005/Bert-sms-spam-detector-onnx")
session = ort.InferenceSession(onnx_model_path, providers=["CPUExecutionProvider"])
text = "Congratulations! You won a free prize."
inputs = tokenizer(text, return_tensors="np", padding="max_length", truncation=True, max_length=64)
onnx_inputs = {
"input_ids": inputs["input_ids"].astype(np.int64),
"attention_mask": inputs["attention_mask"].astype(np.int64)
}
outputs = session.run(None, onnx_inputs)
logits = outputs[0]
predicted_class = int(np.argmax(logits, axis=1)[0])
class_map = {0: "Ham (Not Spam)", 1: "Spam"}
print(f"Predicted class: {class_map[predicted_class]}")
Model info
onnx
license:mit
region:us
↓ 0
♥ 0
Created: 2025-09-29
Updated: 2025-09-29
View on Hugging FaceFiles (7)
.gitattributes
README.md
bert_sms_detector.onnx
ONNX
special_tokens_map.json
tokenizer.json
tokenizer_config.json
vocab.txt
Related models
More from alanjoshua2005
More models
No task type declared.