Skip to content

Commit 34589cc

Browse files
authored
Add MoboleGaze model and update docs (#223)
1 parent fd82a5d commit 34589cc

135 files changed

Lines changed: 43582 additions & 493 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docs.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Deploy MkDocs Documentation
2+
on:
3+
push:
4+
branches: [ main ]
5+
paths: [ 'docs/**', 'mkdocs.yml' ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Setup Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: '3.11'
27+
28+
- name: Install dependencies
29+
run: |
30+
pip install mkdocs-material pymdown-extensions
31+
32+
- name: Build documentation
33+
run: mkdocs build
34+
35+
- name: Upload artifact
36+
uses: actions/upload-pages-artifact@v3
37+
with:
38+
path: ./site
39+
40+
deploy:
41+
environment:
42+
name: github-pages
43+
url: ${{ steps.deployment.outputs.page_url }}
44+
runs-on: ubuntu-latest
45+
needs: build
46+
if: github.ref == 'refs/heads/main'
47+
steps:
48+
- name: Deploy to GitHub Pages
49+
id: deployment
50+
uses: actions/deploy-pages@v4

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,8 @@ required-features = ["vision", "annotator"]
314314
name = "sapiens"
315315
path = "examples/sapiens/main.rs"
316316
required-features = ["vision", "annotator"]
317+
318+
[[example]]
319+
name = "gaze-estimation"
320+
path = "examples/gaze-estimation/main.rs"
321+
required-features = ["vision", "annotator", "video"]

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,15 @@ cargo run -r --example yolo -- --help
211211

212212
</details>
213213

214+
<details closed>
215+
<summary><b>👀 Gaze Estimation</b></summary>
216+
217+
| Model | Task / Description | Demo | Dynamic Batch | TensorRT | FP32 | FP16 | Q8 | Q4f16 | BNB4 |
218+
| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
219+
| [MobileGaze](https://github.com/yakhyo/gaze-estimation) | Eye Gaze Estimation | [demo](./examples/pose-estimation) ||||||||
220+
221+
</details>
222+
214223
<details closed>
215224
<summary><b>✂️ Image Matting & Portrait Segmentation</b></summary>
216225

assets/gaze.png

895 KB
Loading

docs/cargo-features/overview.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Cargo Features
2+
3+
**usls** is highly modular. Use feature flags to include only the models and hardware support you need, keeping your binary small and compilation fast.
4+
5+
Features in ***italics*** are enabled by default.
6+
7+
### Core & Utilities
8+
- ***`ort-download-binaries`***: Automatically download prebuilt ONNX Runtime binaries from [pyke](https://ort.pyke.io/perf/execution-providers).
9+
- **`ort-load-dynamic`**: Manually link ONNX Runtime. Useful for custom builds or unsupported platforms. See [Linking Guide](https://ort.pyke.io/setup/linking#static-linking) for more details.
10+
- **`viewer`**: Real-time image/video visualization (similar to OpenCV `imshow`). Empowered by [minifb](https://github.com/emoon/rust_minifb).
11+
- **`video`**: Video I/O support for reading and writing video streams. Empowered by [video-rs](https://github.com/oddity-ai/video-rs).
12+
- **`hf-hub`**: Download model files from Hugging Face Hub.
13+
- ***`annotator`***: Annotation utilities for drawing bounding boxes, keypoints, and masks on images.
14+
15+
### Image Formats
16+
Additional image format support (optional for faster compilation):
17+
18+
- **`image-all-formats`**: Enable all additional image formats.
19+
- **`image-gif`**, **`image-bmp`**, **`image-ico`**, **`image-avif`**, **`image-tiff`**, **`image-dds`**, **`image-exr`**, **`image-ff`**, **`image-hdr`**, **`image-pnm`**, **`image-qoi`**, **`image-tga**: Individual image format support.
20+
21+
### Model Categories
22+
- ***`vision`***: Core vision models (Detection, Segmentation, Classification, Pose, etc.).
23+
- **`vlm`**: Vision-Language Models (CLIP, BLIP, Florence2, etc.).
24+
- **`mot`**: Multi-Object Tracking utilities.
25+
- **`all-models`**: Enable all model categories.
26+
27+
### Execution Providers
28+
Hardware acceleration for inference. Enable the one matching your hardware:
29+
30+
- **`cuda`**: NVIDIA CUDA execution provider (pure model inference acceleration).
31+
- **`tensorrt`**: NVIDIA TensorRT execution provider (pure model inference acceleration).
32+
- **`nvrtx`**: NVIDIA NvTensorRT-RTX execution provider (pure model inference acceleration).
33+
- **`cuda-full`**: `cuda` + `cuda-runtime-build` (Model + Image Preprocessing acceleration).
34+
- **`tensorrt-full`**: `tensorrt` + `cuda-runtime-build` (Model + Image Preprocessing acceleration).
35+
- **`nvrtx-full`**: `nvrtx` + `cuda-runtime-build` (Model + Image Preprocessing acceleration).
36+
- **`coreml`**: Apple Silicon (macOS/iOS).
37+
- **`openvino`**: Intel CPU/GPU/VPU.
38+
- **`onednn`**: Intel Deep Neural Network Library.
39+
- **`directml`**: DirectML (Windows).
40+
- **`webgpu`**: WebGPU (Web/Chrome).
41+
- **`rocm`**: AMD GPU acceleration.
42+
- **`cann`**: Huawei Ascend NPU.
43+
- **`rknpu`**: Rockchip NPU.
44+
- **`xnnpack`**: Mobile CPU optimization.
45+
- **`acl`**: Arm Compute Library.
46+
- **`armnn`**: Arm Neural Network SDK.
47+
- **`azure`**: Azure ML execution provider.
48+
- **`migraphx`**: AMD MIGraphX.
49+
- **`nnapi`**: Android Neural Networks API.
50+
- **`qnn`**: Qualcomm SNPE.
51+
- **`tvm`**: Apache TVM.
52+
- **`vitis`**: Xilinx Vitis AI.
53+
54+
### CUDA Support
55+
NVIDIA GPU acceleration with CUDA image processing kernels (requires `cudarc`):
56+
57+
- **`cuda-full`**: Uses `cuda-version-from-build-system` (auto-detects via `nvcc`).
58+
- **`cuda-11040`**, **`cuda-11050`**, **`cuda-11060`**, **`cuda-11070`**, **`cuda-11080`**: CUDA 11.x versions (Model + Preprocess).
59+
- **`cuda-12000`**, **`cuda-12010`**, **`cuda-12020`**, **`cuda-12030`**, **`cuda-12040`**, **`cuda-12050`**, **`cuda-12060`**, **`cuda-12080`**, **`cuda-12090`**: CUDA 12.x versions (Model + Preprocess).
60+
- **`cuda-13000`**, **`cuda-13010`**: CUDA 13.x versions (Model + Preprocess).
61+
62+
### TensorRT Support
63+
NVIDIA TensorRT execution provider with CUDA runtime libraries:
64+
65+
- **`tensorrt-full`**: Uses `cuda-version-from-build-system` (auto-detects via `nvcc`).
66+
- **`tensorrt-cuda-11040`**, **`tensorrt-cuda-11050`**, **`tensorrt-cuda-11060`**, **`tensorrt-cuda-11070`**, **`tensorrt-cuda-11080`**: TensorRT + CUDA 11.x runtime.
67+
- **`tensorrt-cuda-12000`**, **`tensorrt-cuda-12010`**, **`tensorrt-cuda-12020`**, **`tensorrt-cuda-12030`**, **`tensorrt-cuda-12040`**, **`tensorrt-cuda-12050`**, **`tensorrt-cuda-12060`**, **`tensorrt-cuda-12080`**, **`tensorrt-cuda-12090`**: TensorRT + CUDA 12.x runtime.
68+
- **`tensorrt-cuda-13000`**, **`tensorrt-cuda-13010`**: TensorRT + CUDA 13.x runtime.
69+
70+
> **Note**: `tensorrt-cuda-*` features enable **TensorRT execution provider** with CUDA runtime libraries for image processing. The "cuda" in the name refers to `cudarc` dependency.
71+
72+
### NVRTX Support
73+
NVIDIA NvTensorRT-RTX execution provider with CUDA runtime libraries:
74+
75+
- **`nvrtx-full`**: Uses `cuda-version-from-build-system` (auto-detects via `nvcc`).
76+
- **`nvrtx-cuda-11040`**, **`nvrtx-cuda-11050`**, **`nvrtx-cuda-11060`**, **`nvrtx-cuda-11070`**, **`nvrtx-cuda-11080`**: NVRTX + CUDA 11.x runtime.
77+
- **`nvrtx-cuda-12000`**, **`nvrtx-cuda-12010`**, **`nvrtx-cuda-12020`**, **`nvrtx-cuda-12030`**, **`nvrtx-cuda-12040`**, **`nvrtx-cuda-12050`**, **`nvrtx-cuda-12060`**, **`nvrtx-cuda-12080`**, **`nvrtx-cuda-12090`**: NVRTX + CUDA 12.x runtime.
78+
- **`nvrtx-cuda-13000`**, **`nvrtx-cuda-13010`**: NVRTX + CUDA 13.x runtime.
79+
80+
> **Note**: `nvrtx-cuda-*` features enable **NVRTX execution provider** with CUDA runtime libraries for image processing. The "cuda" in the name refers to `cudarc` dependency.
81+
82+
---
83+
84+
## 🚀 Device Combination Guide
85+
86+
| Scenario | Model Device (`--device`) | Processor Device (`--processor-device`) | Required Features (`-F`) |
87+
| :--- | :--- | :--- | :--- |
88+
| **CPU Only** | `cpu` | `cpu` | `vision` (default) |
89+
| **GPU Inference (Slow Preprocess)** | `cuda` | `cpu` | `cuda` |
90+
| **GPU Inference (Fast Preprocess)** | `cuda` | `cuda` | `cuda-full` or `cuda-120xxx` |
91+
| **TensorRT (Slow Preprocess)** | `tensorrt` | `cpu` | `tensorrt` |
92+
| **TensorRT (Fast Preprocess)** | `tensorrt` | `cuda` | `tensorrt-full` or `tensorrt-cuda-120xxx` |
93+
94+
> ⚠️ In multi-GPU environments (e.g., `cuda:0`, `cuda:1`), you **MUST** ensure that both `--device` and `--processor-device` use the **SAME GPU ID**.
95+
96+
---
97+
98+
## Common Pitfalls
99+
100+
```toml
101+
# ❌ Don't mix multiple CUDA versions
102+
features = ["cuda-12040", "cuda-11080"]
103+
104+
# ✅ Use one execution provider
105+
features = ["tensorrt-full"]
106+
107+
# ✅ Use two execution provider: cuda EP + tensorrt EP + cuda image processing
108+
features = ["cuda-full", "tensorrt"]
109+
features = ["cuda", "tensorrt-full"]
110+
111+
112+
```

docs/contributing.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributing
2+
***TODO***
3+
4+
<!--
5+
We welcome contributions to **usls**! Whether you're fixing bugs, adding new models, or improving documentation, your help is appreciated.
6+
## 🛠️ Development Setup
7+
8+
1. **Fork & Clone**:
9+
```bash
10+
git clone https://github.com/your-username/usls.git
11+
cd usls
12+
```
13+
14+
2. **Install Dependencies**: Ensure you have Rust (MSRV 1.87) and ONNX Runtime installed.
15+
16+
3. **Run Tests**:
17+
```bash
18+
cargo test
19+
```
20+
21+
## 🚀 Adding New Models
22+
23+
If you'd like to contribute a new model to the Model Zoo:
24+
25+
1. **Logic**: Implement the model logic in `src/models/`.
26+
2. **Config**: Add necessary configuration options in `src/config/`.
27+
3. **Example**: Provide a working example in `examples/`.
28+
4. **Documentation**: Update the corresponding page in `docs/model-zoo/`.
29+
30+
## 📜 Coding Guidelines
31+
32+
- **Consistency**: Follow the existing naming conventions (e.g., `with_<module>_<field>` for configs).
33+
- **Formatting**: Use `cargo fmt` before submitting a PR.
34+
- **Linting**: Ensure `cargo clippy` passes without warnings.
35+
36+
## 🤝 Pull Request Process
37+
38+
1. Create a new branch for your feature or bugfix.
39+
2. Ensure all tests pass and documentation is updated.
40+
3. Submit a PR with a clear description of the changes. -->
41+
42+
---
43+
44+
!!! info "Questions?"
45+
If you're unsure where to start, feel free to open a [discussion](https://github.com/jamjamjon/usls/discussions) or join our community.
46+

docs/faq.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# FAQ
2+
3+
***TODO***
4+
5+
<!--
6+
7+
Frequently asked questions about **usls**.
8+
## 🚀 General
9+
10+
??? question "How do I install usls?"
11+
Add usls to your `Cargo.toml`. See the [Installation](getting-started/installation.md) guide for details.
12+
13+
??? question "What are the minimum requirements?"
14+
- Rust 1.87+
15+
- ONNX Runtime 1.22.0+
16+
- (Optional) CUDA 11/12 or TensorRT 10 for GPU acceleration.
17+
18+
## 🔧 Configuration
19+
20+
??? question "CUDA vs. TensorRT?"
21+
- **CUDA**: Easier setup, good flexibility.
22+
- **TensorRT**: Maximum performance, requires an initial engine building step.
23+
24+
??? question "Model Device vs. Processor Device?"
25+
- **Model Device**: Where the neural network runs (Inference).
26+
- **Processor Device**: Where image resizing and normalization happen (Preprocessing).
27+
28+
## 🎯 Model Usage
29+
30+
??? question "Can I use custom models?"
31+
Yes, you can load any ONNX model using `Config::from_file("model.onnx")`.
32+
33+
??? question "How do I optimize for speed?"
34+
- Use `DType::Fp16`.
35+
- Enable `TensorRT`.
36+
- Use GPU preprocessing (`Device::Cuda(0)` for both model and processor).
37+
38+
## 🐛 Troubleshooting
39+
40+
??? question "CUDA not available error?"
41+
Ensure you have the NVIDIA drivers and CUDA toolkit installed, and that you've enabled the `cuda` or `cuda-full` feature in your `Cargo.toml`.
42+
43+
??? question "Out of Memory (OOM)?"
44+
- Reduce the batch size.
45+
- Use half-precision (`Fp16`).
46+
- Use quantized models (`Q4`, `Q8`).
47+
48+
--- -->
49+
50+
!!! info "Still have questions?"
51+
If you can't find what you're looking for, feel free to open a [GitHub Issue](https://github.com/jamjamjon/usls/issues).
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Installation
2+
3+
To use **usls** in your project, add it to your `Cargo.toml`.
4+
5+
=== "Crates.io"
6+
7+
```toml
8+
[dependencies]
9+
usls = { version = "latest-version", features = [ "cuda" ] }
10+
```
11+
12+
=== "GitHub (Recommended)"
13+
14+
```toml
15+
[dependencies]
16+
usls = { git = "https://github.com/jamjamjon/usls", branch = "main" }
17+
```
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Integration Workflow
2+
3+
`usls` implements a clean, modular pipeline from data ingestion to results visualization.
4+
5+
## The 4-Step Pipeline
6+
7+
1. **Configure Model**: Select a pre-configured model (e.g., `Config::rfdetr_nano()`), customize settings, and commit the configuration.
8+
2. **Load Data**: Setup a `DataLoader` to handle your input sources (images, videos, etc.).
9+
3. **Inference**: Iterate through the `DataLoader` and pass data to `model.run()` or `model.forward()`.
10+
4. **Extract Results**: Access detections, masks, or embeddings from the unified `Y` output.
11+
5. **Annotate (Optional)**: Use the `Annotator` to draw results back onto the original images.
12+
6. **Visualize (Optional)**: Use the `Viewer` for real-time display or video recording.
13+
14+
## Basic Usage Example
15+
16+
```rust
17+
use usls::*;
18+
19+
fn main() -> anyhow::Result<()> {
20+
// 1. Configure & Build Model
21+
let config = Config::rfdetr_nano()
22+
.with_model_device(Device::Cuda(0))
23+
.commit()?;
24+
let mut model = RFDETR::new(config)?;
25+
26+
// 2. Setup DataLoader
27+
let dl = DataLoader::new("image.jpg")?
28+
.with_batch(model.batch())
29+
.stream()?;
30+
31+
// optional: Annotate
32+
let annotator = Annotator::default();
33+
34+
// optional: Viewer
35+
let mut viewer = Viewer::default();
36+
37+
// 3. Run Inference
38+
for xs in dl {
39+
let ys = model.run(&xs)?;
40+
for (x, y) in xs.iter().zip(ys.iter()) {
41+
// 4. Access results
42+
for hb in y.hbbs() {
43+
println!("{}", hb);
44+
}
45+
46+
// optional: Check if the window is closed and exit if so.
47+
if viewer.is_window_exist_and_closed() {
48+
break;
49+
}
50+
51+
// optional: Annotate
52+
let image_annotated = annotator.annotate(x, y)?;
53+
54+
// optional: Display the current image.
55+
viewer.imshow(&image_annotated)?;
56+
57+
// optional: Wait for a key press or timeout, and exit on Escape.
58+
if let Some(key) = viewer.wait_key(10) {
59+
if key == usls::Key::Escape {
60+
break;
61+
}
62+
}
63+
64+
// optional: Save the annotated image.
65+
image_annotated.save("output.jpg")?;
66+
}
67+
}
68+
Ok(())
69+
}
70+
```

docs/getting-started/overview.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Getting Started Overview
2+
<p align="center">
3+
<img src="https://github.com/jamjamjon/assets/releases/download/images/pipeline.png" width="800">
4+
</p>
5+
6+
**usls** is a cross-platform Rust library powered by ONNX Runtime for efficient inference of SOTA vision and vision-language models (***typically under 1B parameters***).
7+
8+
9+
## 🌟 Highlights
10+
11+
- **⚡ High Performance**: Multi-threading, SIMD, and CUDA-accelerated processing
12+
- **🌐 Cross-Platform**: Linux, macOS, Windows with ONNX Runtime execution providers (CUDA, TensorRT, CoreML, OpenVINO, DirectML, etc.)
13+
- **🏗️ Unified API**: Single `Model` trait inference with `run()`/`forward()`/`encode_images()`/`encode_texts()` and unified `Y` output
14+
- **📥 Auto-Management**: Automatic model download (HuggingFace/GitHub), caching and path resolution
15+
- **📦 Multiple Inputs**: Image, directory, video, webcam, stream and combinations
16+
- **🎯 Precision Support**: FP32, FP16, INT8, UINT8, Q4, Q4F16, BNB4, and more
17+
- **🛠️ Full-Stack Suite**: `DataLoader`, `Annotator`, and `Viewer` for complete workflows
18+
- **🌱 Model Ecosystem**: 50+ SOTA vision and VLM models

0 commit comments

Comments
 (0)