mohamedsamyy/Saudi-EOU
By mohamedsamyy · ↓ 0 · ♥ 0 · Updated 2025-12-12
What's in this repo
This page lists the files in mohamedsamyy/Saudi-EOU, including Saudi_EOU.onnx.
- 1 ONNX models (.onnx files)
- 8 files, including 3 .json, 1 .md, 1 .onnx, 1 .pth, 1 .txt
- Last updated 2025-12-12
ONNX files
| File | Size | Download |
|---|---|---|
| Saudi_EOU.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
Usage
import numpy as np
import onnxruntime as ort
from transformers import AutoTokenizer
from huggingface_hub import hf_hub_download
import time
class SaudiEOU:
def __init__(self, repo_id="mohamedsamyy/Saudi-EOU"):
print(f"Loading model from repo: {repo_id}")
model_path = hf_hub_download(repo_id=repo_id, filename="Saudi_EOU.onnx")
self.tokenizer = AutoTokenizer.from_pretrained(repo_id)
self.session = ort.InferenceSession(model_path, providers=["CUDAExecutionProvider"])
self.max_length = 128
print("✅ Model and tokenizer loaded successfully.")
def predict(self, text: str) -> tuple:
inputs = self.tokenizer(text, truncation=True, max_length=self.max_length, return_tensors="np")
feed_dict = {"input_ids": inputs["input_ids"], "attention_mask": inputs["attention_mask"]}
start = time.perf_counter()
outputs = self.session.run(None, feed_dict)
logits = outputs[0][0]
confidence = self._sigmoid(logits[0])
end = time.perf_counter()
print(f"'{text}' -> latency: {end - start:.4f}s")
predicted_label = 1 if confidence >= 0.5 else 0
return predicted_label, confidence
def _sigmoid(self, x):
return 1 / (1 + np.exp(-x))
# Example usage
detector = SaudiEOU()
sentences = ["حياك الله", "ممم", "اهلا", "يا هلا ", "السلام عليكم"]
for sentence in sentences:
predicted_label, confidence = detector.predict(sentence)
result = "End of Turn" if predicted_label == 1 else "Not End of Turn"
print(f"'{sentence}' -> {result} (confidence: {confidence:.3f})")
This example shows how to load the SaudiEOU ONNX model from the Hugging Face Hub and predict if a sentence is an end-of-turn utterance. The model runs on GPU if available, and prints the latency per sentence.
Model info
Created: 2025-12-12
Updated: 2025-12-12
View on Hugging FaceFiles (8)
Related models
More from mohamedsamyy
No other models by this author.