mas-lwym 🚀
mas-lwym is an ultra-lightweight, high-accuracy, single-class (person) object detection library designed for extreme cost efficiency and high throughput on commodity CPUs, edge devices, and GPUs.
Built from the ground up for production deployment, mas-lwym runs exclusively on ONNX Runtime with pure NumPy/OpenCV pre/post-processing, zero runtime framework bloat, seamless CPU/GPU hardware toggles, and 100% Apache-2.0 commercial compliance.
🌟 Key Features
- ⚡ Ultra-Lightweight & Fast: Sub-5ms latency and 150–250+ FPS on standard CPUs.
- 🎯 Single-Class Person Focus: Eliminates multi-class softmax/NMS overhead for maximum efficiency.
- 💻 Pure ONNX Runtime Core: No heavy PyTorch or PaddlePaddle dependencies needed during inference.
- 🔄 Seamless Hardware Toggle: Switch between
device="cpu"anddevice="gpu"with automatic graceful fallback. - 🛠️ Integrated Converter: Built-in
convert_to_onnx()utility to convert checkpoints (.pdparams, .pdmodel) to standalone, graph-optimized ONNX models. - 📊 Profiling & Diagnostics: Built-in latency (P50/P95/P99), FPS, and hardware execution provider benchmark suite.
- ⚖️ Commercial Friendly: Free from copyleft/AGPL constraints (Apache-2.0).
📦 Installation
# Using uv (recommended)
uv add mas-lwym
# Or using pip
pip install mas-lwym
🚀 Quickstart
1. Python API
import cv2
from mas_lwym import PersonDetector
# Initialize detector (CPU by default, or device="gpu" / "cuda" / "directml")
detector = PersonDetector(
model_path="models/picodet_s_320_pedestrian.onnx",
device="cpu", # "cpu" | "gpu" | "cuda" | "directml"
confidence_threshold=0.40,
iou_threshold=0.45,
input_shape=(320, 320),
)
# 1. Run inference on an image
image = cv2.imread("street.jpg")
result = detector.predict(image)
print(f"Persons detected: {result.count}")
print(f"Total time: {result.total_time_ms:.2f} ms ({result.fps:.1f} FPS)")
for box in result.boxes:
print(f"Confidence: {box.score:.2f} | Coordinates: {box.xyxy}")
# 2. Render bounding boxes and HUD
annotated_frame = detector.render(image, result, show_fps=True)
cv2.imwrite("output.jpg", annotated_frame)
2. Real-Time Webcam / Video Stream
from mas_lwym import PersonDetector, VideoPipeline
detector = PersonDetector(model_path="models/picodet_s_320_pedestrian.onnx", device="cpu")
pipeline = VideoPipeline(detector)
# Stream from webcam (0) or video file ("video.mp4")
pipeline.process_stream(source=0, show=True)
3. Model Conversion (convert_to_onnx)
from mas_lwym import convert_to_onnx
# Convert Paddle / PicoDet checkpoint to optimized standalone ONNX
convert_to_onnx(
model_path="models/picodet_s_320_pedestrian",
output_path="models/picodet_s_320_pedestrian.onnx",
input_shape=(320, 320),
simplify=True,
)
🖥️ Command-Line Interface (CLI)
Check Hardware & Available Execution Providers
mas-lwym devices
Benchmark Model Latency & FPS
mas-lwym benchmark --model models/picodet_s_320_pedestrian.onnx --device cpu --iterations 100
Run Detection via CLI
mas-lwym detect --model models/picodet_s_320_pedestrian.onnx --source frame.jpg --device cpu --save output.jpg
Convert Checkpoints to ONNX
mas-lwym convert --input models/picodet_s_320_pedestrian --output models/picodet_s_320_pedestrian.onnx --shape 320
📂 Package Architecture
src/mas_lwym/
├── core/ # Typed dataclasses (BoundingBox, DetectionResult, DeviceType)
├── engine/ # ONNX Runtime session & hardware provider management
├── processing/ # Vectorized letterbox preprocessor, single-class NMS, visualizer
├── converter/ # Checkpoint to ONNX export router & graph optimizer
├── pipeline/ # High-level PersonDetector and VideoPipeline streams
├── benchmark/ # Latency percentiles (P50/P95/P99) & throughput profiler
└── cli/ # Unified command line tool (mas-lwym)
📄 License
This project is licensed under the Apache License 2.0 - free for both commercial and personal use.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mas_lwym-0.1.1.tar.gz.
File metadata
- Download URL: mas_lwym-0.1.1.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5edb7461777452e09feaa7271c6124f2b42706b8ae33100021adc33498c3f6d
|
|
| MD5 |
be483348e0c2156180e13b6cb0cd490c
|
|
| BLAKE2b-256 |
7eab6edf06b2c2cf042f224fbc4c84fcaf051a96cebc3f1f18c41b8cbadb5976
|
File details
Details for the file mas_lwym-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mas_lwym-0.1.1-py3-none-any.whl
- Upload date:
- Size: 26.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e48eb9d90df4c24c6fa206c3b6393141501a6458f5ef0cb5ad355f0c691ea05
|
|
| MD5 |
57116289a3e1272e130fefc60aeab941
|
|
| BLAKE2b-256 |
e7f74bd7ada46301ca6d8b1c79c2d5f74e484bd7bcc42473e0511f273767ec7c
|