ai-inference 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ai-inference might be problematic. Click here for more details.
- ai_inference-0.2.1/CHANGELOG.md +90 -0
- ai_inference-0.2.1/LICENSE +21 -0
- ai_inference-0.2.1/MANIFEST.in +12 -0
- ai_inference-0.2.1/PKG-INFO +185 -0
- ai_inference-0.2.1/README.md +156 -0
- ai_inference-0.2.1/configs/rfdetr.yaml +48 -0
- ai_inference-0.2.1/configs/rfdetr_om.yaml +32 -0
- ai_inference-0.2.1/configs/rtdetr.yaml +37 -0
- ai_inference-0.2.1/configs/sface.yaml +35 -0
- ai_inference-0.2.1/configs/yolo11.yaml +49 -0
- ai_inference-0.2.1/configs/yunet.yaml +38 -0
- ai_inference-0.2.1/docs/architecture.md +50 -0
- ai_inference-0.2.1/docs/configuration.md +276 -0
- ai_inference-0.2.1/docs/extension.md +97 -0
- ai_inference-0.2.1/docs/logging-and-benchmark.md +77 -0
- ai_inference-0.2.1/docs/model-downloads.md +42 -0
- ai_inference-0.2.1/docs/pipeline.md +132 -0
- ai_inference-0.2.1/docs/releases/actions.md +119 -0
- ai_inference-0.2.1/docs/service/README.md +136 -0
- ai_inference-0.2.1/docs/service/release-plan.md +97 -0
- ai_inference-0.2.1/docs/service/review.md +33 -0
- ai_inference-0.2.1/docs/testing.md +144 -0
- ai_inference-0.2.1/examples/README.md +63 -0
- ai_inference-0.2.1/examples/rfdetr.py +17 -0
- ai_inference-0.2.1/examples/rtdetr.py +17 -0
- ai_inference-0.2.1/examples/service.py +63 -0
- ai_inference-0.2.1/examples/sface.py +27 -0
- ai_inference-0.2.1/examples/yolo11.py +17 -0
- ai_inference-0.2.1/examples/yunet.py +17 -0
- ai_inference-0.2.1/pyproject.toml +89 -0
- ai_inference-0.2.1/requirements/ascend.txt +9 -0
- ai_inference-0.2.1/scripts/README.md +47 -0
- ai_inference-0.2.1/scripts/benchmark.py +139 -0
- ai_inference-0.2.1/scripts/check_dist.py +105 -0
- ai_inference-0.2.1/scripts/clean_python_cache.py +37 -0
- ai_inference-0.2.1/scripts/export_rfdetr.py +80 -0
- ai_inference-0.2.1/scripts/export_rtdetr.py +107 -0
- ai_inference-0.2.1/scripts/predict_all.py +139 -0
- ai_inference-0.2.1/scripts/processing_reference.py +64 -0
- ai_inference-0.2.1/scripts/release.py +198 -0
- ai_inference-0.2.1/scripts/smoke.py +50 -0
- ai_inference-0.2.1/scripts/test.py +63 -0
- ai_inference-0.2.1/scripts/verify_faces.py +202 -0
- ai_inference-0.2.1/scripts/verify_predictions.py +169 -0
- ai_inference-0.2.1/scripts/verify_rtdetr.py +196 -0
- ai_inference-0.2.1/setup.cfg +4 -0
- ai_inference-0.2.1/src/ai_inference/__init__.py +57 -0
- ai_inference-0.2.1/src/ai_inference/config.py +95 -0
- ai_inference-0.2.1/src/ai_inference/contracts/__init__.py +1 -0
- ai_inference-0.2.1/src/ai_inference/contracts/data.py +63 -0
- ai_inference-0.2.1/src/ai_inference/contracts/processors.py +20 -0
- ai_inference-0.2.1/src/ai_inference/contracts/registry.py +26 -0
- ai_inference-0.2.1/src/ai_inference/contracts/validation.py +47 -0
- ai_inference-0.2.1/src/ai_inference/engines/__init__.py +8 -0
- ai_inference-0.2.1/src/ai_inference/engines/base.py +183 -0
- ai_inference-0.2.1/src/ai_inference/engines/om.py +79 -0
- ai_inference-0.2.1/src/ai_inference/engines/onnxruntime.py +153 -0
- ai_inference-0.2.1/src/ai_inference/engines/registry.py +5 -0
- ai_inference-0.2.1/src/ai_inference/inference/__init__.py +1 -0
- ai_inference-0.2.1/src/ai_inference/inference/batcher.py +115 -0
- ai_inference-0.2.1/src/ai_inference/inference/predictor.py +60 -0
- ai_inference-0.2.1/src/ai_inference/logging.py +64 -0
- ai_inference-0.2.1/src/ai_inference/model.py +250 -0
- ai_inference-0.2.1/src/ai_inference/processing/__init__.py +10 -0
- ai_inference-0.2.1/src/ai_inference/processing/common.py +61 -0
- ai_inference-0.2.1/src/ai_inference/processing/context.py +35 -0
- ai_inference-0.2.1/src/ai_inference/processing/decoders/__init__.py +1 -0
- ai_inference-0.2.1/src/ai_inference/processing/decoders/rfdetr.py +69 -0
- ai_inference-0.2.1/src/ai_inference/processing/decoders/rtdetr.py +63 -0
- ai_inference-0.2.1/src/ai_inference/processing/decoders/sface.py +80 -0
- ai_inference-0.2.1/src/ai_inference/processing/decoders/yolo.py +86 -0
- ai_inference-0.2.1/src/ai_inference/processing/decoders/yunet.py +91 -0
- ai_inference-0.2.1/src/ai_inference/processing/geometry.py +48 -0
- ai_inference-0.2.1/src/ai_inference/processing/pipeline.py +192 -0
- ai_inference-0.2.1/src/ai_inference/processing/steps/__init__.py +1 -0
- ai_inference-0.2.1/src/ai_inference/processing/steps/decode.py +168 -0
- ai_inference-0.2.1/src/ai_inference/processing/steps/postprocess.py +61 -0
- ai_inference-0.2.1/src/ai_inference/processing/steps/preprocess.py +344 -0
- ai_inference-0.2.1/src/ai_inference/py.typed +0 -0
- ai_inference-0.2.1/src/ai_inference/service/__init__.py +1 -0
- ai_inference-0.2.1/src/ai_inference/service/app.py +197 -0
- ai_inference-0.2.1/src/ai_inference/service/inputs.py +212 -0
- ai_inference-0.2.1/src/ai_inference/service/runtime.py +86 -0
- ai_inference-0.2.1/src/ai_inference/service/schemas.py +47 -0
- ai_inference-0.2.1/src/ai_inference/service/settings.py +32 -0
- ai_inference-0.2.1/src/ai_inference/visualization/__init__.py +1 -0
- ai_inference-0.2.1/src/ai_inference/visualization/plotter.py +221 -0
- ai_inference-0.2.1/src/ai_inference.egg-info/PKG-INFO +185 -0
- ai_inference-0.2.1/src/ai_inference.egg-info/SOURCES.txt +120 -0
- ai_inference-0.2.1/src/ai_inference.egg-info/dependency_links.txt +1 -0
- ai_inference-0.2.1/src/ai_inference.egg-info/requires.txt +21 -0
- ai_inference-0.2.1/src/ai_inference.egg-info/top_level.txt +1 -0
- ai_inference-0.2.1/tests/bus.jpg +0 -0
- ai_inference-0.2.1/tests/conftest.py +42 -0
- ai_inference-0.2.1/tests/fixtures/rfdetr_om_synthetic.yaml +30 -0
- ai_inference-0.2.1/tests/fixtures/rfdetr_synthetic.yaml +48 -0
- ai_inference-0.2.1/tests/model_contracts.py +62 -0
- ai_inference-0.2.1/tests/pipeline_helpers.py +26 -0
- ai_inference-0.2.1/tests/test_base_engine.py +96 -0
- ai_inference-0.2.1/tests/test_batcher_predictor.py +76 -0
- ai_inference-0.2.1/tests/test_benchmark.py +72 -0
- ai_inference-0.2.1/tests/test_distribution.py +38 -0
- ai_inference-0.2.1/tests/test_engine_warmup_inputs.py +93 -0
- ai_inference-0.2.1/tests/test_extended.py +412 -0
- ai_inference-0.2.1/tests/test_image_steps.py +71 -0
- ai_inference-0.2.1/tests/test_log_template.py +179 -0
- ai_inference-0.2.1/tests/test_om.py +330 -0
- ai_inference-0.2.1/tests/test_ort.py +385 -0
- ai_inference-0.2.1/tests/test_package_structure.py +67 -0
- ai_inference-0.2.1/tests/test_pipeline.py +170 -0
- ai_inference-0.2.1/tests/test_plotter.py +127 -0
- ai_inference-0.2.1/tests/test_processing_boundaries.py +57 -0
- ai_inference-0.2.1/tests/test_processor_injection.py +79 -0
- ai_inference-0.2.1/tests/test_release.py +284 -0
- ai_inference-0.2.1/tests/test_rfdetr.py +110 -0
- ai_inference-0.2.1/tests/test_service.py +593 -0
- ai_inference-0.2.1/tests/test_step_pipeline.py +394 -0
- ai_inference-0.2.1/tests/test_tensor_boundaries.py +125 -0
- ai_inference-0.2.1/tests/test_tensor_discovery.py +270 -0
- ai_inference-0.2.1/tests/test_warmup.py +82 -0
- ai_inference-0.2.1/tests/test_yolo.py +166 -0
- ai_inference-0.2.1/uv.lock +2064 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Notable SDK and optional HTTP service changes are recorded here, newest first, following
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
|
+
Breaking changes and migration instructions are included in the affected entries.
|
|
6
|
+
|
|
7
|
+
The SDK and optional HTTP service share the `ai-inference` distribution,
|
|
8
|
+
version and release notes. HTTP service changes are identified below.
|
|
9
|
+
|
|
10
|
+
## Unreleased
|
|
11
|
+
|
|
12
|
+
## 0.2.1 - 2026-10-15
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- Move Ascend vendor wheel URLs to `requirements/ascend.txt`; the `ascend` extra remains empty for compatibility and requires separate runtime installation. Distribution metadata no longer includes direct URL dependencies.
|
|
17
|
+
- Declare the MIT license and project links, and add distribution metadata, clean installation and strict Twine checks before publication.
|
|
18
|
+
- Publish new version tags to PyPI through GitHub Actions Trusted Publishing, reusing validated GitHub Release artifacts; manual runs also support TestPyPI or GitHub-only publishing.
|
|
19
|
+
|
|
20
|
+
## 0.2.0 - 2026-10-15
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- Optional single-model HTTP service under `ai_inference.service`; install `ai-inference[service,onnx-cpu]` for CPU serving. The `service` extra adds FastAPI, Uvicorn and multipart dependencies without affecting base SDK imports.
|
|
25
|
+
- File, Base64, URL and encoded-bytes prediction endpoints; detection/embedding responses, per-image SFace five-point inputs, health/model endpoints, request limits and single-request admission.
|
|
26
|
+
- HTTP boundary regression tests, including keypoint propagation through all four input forms; service usage, operations, review and release documentation.
|
|
27
|
+
- HTTP client example for file, Base64, URL and bytes requests, including optional SFace five-point metadata.
|
|
28
|
+
- Composable `Pipeline`, `StepRegistry`, and request-local `Context` / `Geometry`, with ordered YAML steps and validation of parameters, layout, color, device, and geometry.
|
|
29
|
+
- `Predictor` protocol, `DefaultPredictor`, and independent `Batcher` for splitting, padding, trimming, and merging fixed or dynamic batches in input order.
|
|
30
|
+
- Reusable image processing steps, model decoders, `l2_normalize`, and `filter_detections`; custom step registration and full preprocessor/postprocessor injection.
|
|
31
|
+
- Automatic ONNX Runtime and static OM tensor metadata discovery through `BaseEngine`; optional YAML input/output constraints.
|
|
32
|
+
- Initialization logs for original and resolved tensor shapes and validated batch settings; application-provided Loguru context.
|
|
33
|
+
- Independent `Plotter` for boxes, keypoints, masks, and feature summaries, with optional class names and application log context.
|
|
34
|
+
- Standalone benchmark, minimal model examples, multi-model PNG/JSON output, and CPU reference comparison/export tools.
|
|
35
|
+
- uv dependency management and lockfile, dev/test dependency groups, mutually exclusive `onnx-cpu`, `onnx-gpu`, and `ascend` extras, and a Python cache cleanup tool.
|
|
36
|
+
- GitHub Actions workflow for validating tagged SDK sources, building distribution artifacts, and publishing verified GitHub Releases.
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- Package HTTP service code with the SDK, use one version and CHANGELOG, and start it with `uvicorn ai_inference.service.app:app`. Replace the former standalone service installation with the `service` extra.
|
|
41
|
+
- Include service sources, documentation and regression tests in distribution/release checks; tagged releases validate the service extra alongside the SDK.
|
|
42
|
+
- Align the RF-DETR OM example with official Nano COCO defaults (384×384, batch=1, 91 class slots), retain the static AIPP contract, and remove legacy task-specific model names.
|
|
43
|
+
- Organized implementation into `contracts`, `engines`, `inference`, `processing`, and `visualization`. Update internal imports to the corresponding packages; prefer public exports.
|
|
44
|
+
- Require `preprocess.steps` / `postprocess.steps`. Keep only name/path in `model`, device settings in pipelines or steps, class counts in decoders, and display names in `Plotter`.
|
|
45
|
+
- Share CPU/GPU model configuration by changing providers; default YAML files discover model I/O through the engine.
|
|
46
|
+
- Use dynamic batch with a maximum of two samples for the RT-DETR example, symbolic candidate dimensions, and Pillow bilinear antialiased resizing. Deploy outputs require direct resizing without padding.
|
|
47
|
+
- Use 640×640 for YuNet 2023mar and separate SFace feature construction from L2 normalization.
|
|
48
|
+
- Support `cpu` / `cuda` / `trt` provider aliases and ordered lists. A single provider is strict; lists allow explicit initialization and operator fallback. Inference errors are never retried.
|
|
49
|
+
- Require actual OM tensor names instead of aliases. Custom engines must provide `config`, `infer`, and `warmup`.
|
|
50
|
+
- Include the SDK, optional HTTP service and supporting files in one distribution; include service tests in source distributions while excluding weights, build copies and bytecode.
|
|
51
|
+
- Document supported behavior, model sources, reproducible verification and the unified SDK/service release workflow.
|
|
52
|
+
|
|
53
|
+
### Fixed
|
|
54
|
+
|
|
55
|
+
- Enforce the URL download deadline on each socket read and send, TCP connection and TLS handshake; close response streams on all exit paths, including connection-close responses.
|
|
56
|
+
- Validate model support for face keypoints, degenerate alignment geometry and 112×112 aligned crops before inference; return indexed 422 errors without misclassifying genuine model failures.
|
|
57
|
+
- Reject static model batch sizes that conflict with YAML settings, reporting the tensor and corrective settings. Resolve symbolic batch dimensions according to the configured fixed or dynamic policy.
|
|
58
|
+
- Validate injected postprocessor result types and counts against the number of real input samples.
|
|
59
|
+
- Restore YuNet boxes and keypoints through composed resize/padding geometry.
|
|
60
|
+
- Validate RT-DETR output shapes at runtime and reject preprocessing incompatible with deploy coordinates.
|
|
61
|
+
|
|
62
|
+
### Removed
|
|
63
|
+
|
|
64
|
+
- `Adapter`, `AdapterRegistry`, legacy processors, internal forwarding modules, `BatchPredictor`, and `batching.execute`. Use `Model`, `Pipeline`, and `DefaultPredictor`.
|
|
65
|
+
- `Prediction.class_names`, SDK-generated request/instance IDs, timing state, and the `Model` request ID argument. Pass names to `Plotter`, bind application log fields, and use the standalone benchmark.
|
|
66
|
+
- The second `Model.postprocess` argument. Pass only `RawOutput`, which carries the original request metadata.
|
|
67
|
+
- RF-DETR per-class `thresholds`. Use a single `threshold` (default 0.4) and apply further class-specific filtering in the application; discarded candidates cannot be recovered.
|
|
68
|
+
- Model provenance, hash, and adoption records from SDK configuration and loading. Manage these in the deployment application.
|
|
69
|
+
- Legacy `cpu` / `ort` extras and the `test` installation extra. Use `onnx-cpu` / `onnx-gpu` / `ascend` for runtime dependencies and `uv sync --locked` for development. Ascend vendor wheels support Linux x86_64/aarch64 with CPython 3.10–3.12; install CANN and drivers separately.
|
|
70
|
+
- Legacy YAML/example entry points and the RF-DETR service comparison branch in `verify_predictions.py`; that tool now compares YOLO only. Use the current examples and RF-DETR export tool.
|
|
71
|
+
|
|
72
|
+
## 0.1.0 - 2026-10-13
|
|
73
|
+
|
|
74
|
+
### Added
|
|
75
|
+
|
|
76
|
+
- Initial Adapter / Processor / Engine architecture with shared `Model`, `Config`, registries, and `PreparedInput` / `RawOutput` boundaries.
|
|
77
|
+
- RF-DETR, YOLOv8 / YOLO11, RT-DETR deploy, YuNet 2023mar, and SFace 2021dec processing with ONNX Runtime and static OM backends, including RF-DETR AIPP inputs.
|
|
78
|
+
- `FaceInput`, `FeaturePrediction`, public result/input types, and optional detection keypoints and masks.
|
|
79
|
+
- Fixed/dynamic batches, `repeat_last` / `zeros` padding, ordered results, and configurable warmup.
|
|
80
|
+
- Model provenance and optional ONNX hash validation.
|
|
81
|
+
- Model configuration, examples, and synthetic regression checks.
|
|
82
|
+
|
|
83
|
+
### Changed
|
|
84
|
+
|
|
85
|
+
- Standardized the distribution name as `ai-inference` and the import name as `ai_inference`; update imports and reinstall when migrating from earlier names.
|
|
86
|
+
|
|
87
|
+
### Fixed
|
|
88
|
+
|
|
89
|
+
- Validate requested and loaded ONNX Runtime providers and model I/O names, dtypes, ranks, and static dimensions.
|
|
90
|
+
- Disable automatic runtime retry and prohibit CPU graph fallback unless CPU is explicitly configured.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jasper Tao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include CHANGELOG.md
|
|
3
|
+
include uv.lock
|
|
4
|
+
recursive-include configs *.yaml
|
|
5
|
+
recursive-include docs *.md
|
|
6
|
+
recursive-include examples *.py *.md
|
|
7
|
+
recursive-include tests *.py *.yaml *.jpg
|
|
8
|
+
recursive-include scripts *.py *.md
|
|
9
|
+
global-exclude *.local.yaml *.local.yml
|
|
10
|
+
global-exclude __pycache__ *.py[cod]
|
|
11
|
+
include LICENSE
|
|
12
|
+
recursive-include requirements *.txt
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ai-inference
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: Pipeline-based model inference SDK with a transport-independent engine boundary
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/Jasper-T/ai-inference
|
|
7
|
+
Project-URL: Documentation, https://github.com/Jasper-T/ai-inference#readme
|
|
8
|
+
Project-URL: Repository, https://github.com/Jasper-T/ai-inference
|
|
9
|
+
Project-URL: Issues, https://github.com/Jasper-T/ai-inference/issues
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: numpy<3,>=1.24
|
|
14
|
+
Requires-Dist: opencv-python-headless<5,>=4.8
|
|
15
|
+
Requires-Dist: PyYAML<7,>=6
|
|
16
|
+
Requires-Dist: pydantic<3,>=2.6
|
|
17
|
+
Requires-Dist: Pillow<13,>=9.5
|
|
18
|
+
Requires-Dist: loguru<1,>=0.7
|
|
19
|
+
Provides-Extra: service
|
|
20
|
+
Requires-Dist: fastapi<1,>=0.115; extra == "service"
|
|
21
|
+
Requires-Dist: uvicorn<1,>=0.30; extra == "service"
|
|
22
|
+
Requires-Dist: python-multipart<1,>=0.0.18; extra == "service"
|
|
23
|
+
Provides-Extra: onnx-cpu
|
|
24
|
+
Requires-Dist: onnxruntime<2,>=1.18; extra == "onnx-cpu"
|
|
25
|
+
Provides-Extra: onnx-gpu
|
|
26
|
+
Requires-Dist: onnxruntime-gpu<2,>=1.18; (platform_system == "Linux" or platform_system == "Windows") and extra == "onnx-gpu"
|
|
27
|
+
Provides-Extra: ascend
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# ai-inference
|
|
31
|
+
|
|
32
|
+
通用 Python 模型推理 SDK,通过有序 Pipeline 执行前后处理,Engine 执行模型,Batcher 负责分批、补齐和结果合并。发行包名为 `ai-inference`,Python 导入名为 `ai_inference`。
|
|
33
|
+
|
|
34
|
+
支持 ONNX Runtime 和静态 Ascend OM,提供 RF-DETR、YOLOv8 / YOLO11、RT-DETR、YuNet 和 SFace 的处理步骤。检测结果可包含关键点和掩码;当前没有内置分割模型。HTTP 接口由可选的 [service](docs/service/README.md) 模块提供,与 SDK 使用同一发行包及版本;通过 `service` extra 安装 HTTP 依赖。
|
|
35
|
+
|
|
36
|
+
## 安装
|
|
37
|
+
|
|
38
|
+
Python >= 3.10。项目使用 [uv](https://docs.astral.sh/uv/) 管理依赖、环境、测试和构建。先安装 uv,再从仓库根目录运行:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# 开发环境:SDK、CPU ONNX Runtime、pytest、ONNX 和 Ruff
|
|
42
|
+
uv sync --locked
|
|
43
|
+
|
|
44
|
+
# CPU 运行环境,包括 macOS
|
|
45
|
+
uv sync --locked --no-default-groups --extra onnx-cpu
|
|
46
|
+
|
|
47
|
+
# NVIDIA Linux / Windows 运行环境
|
|
48
|
+
uv sync --locked --no-default-groups --extra onnx-gpu
|
|
49
|
+
|
|
50
|
+
# Ascend Linux 运行环境,CANN、驱动和设备环境须单独准备
|
|
51
|
+
uv sync --locked --python 3.12 --no-default-groups --extra ascend
|
|
52
|
+
uv pip install --python .venv/bin/python -r requirements/ascend.txt
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
需要 HTTP 服务时可组合安装:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install './ai_inference-0.2.1-py3-none-any.whl[service,onnx-cpu]'
|
|
59
|
+
# 在本仓库安装 CPU 服务运行环境
|
|
60
|
+
uv sync --locked --no-default-groups --extra service --extra onnx-cpu
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`0.2.1` 包含 `service` extra。上面的 wheel 命令在从 GitHub Release 下载制品后执行;新版本标签推送会发布 GitHub Release 并上传 PyPI,手动运行时也可选择仅 GitHub Release、TestPyPI 或 PyPI(需先配置 Trusted Publishing,见[发布说明](docs/releases/actions.md#通过-actions-上传-pypi))。包名安装要求对应版本存在于所用包索引。基础安装不引入 FastAPI/Uvicorn,服务代码包含在统一 wheel 中。
|
|
64
|
+
|
|
65
|
+
三个后端 extras 互斥。默认 dev/test 组包含 CPU ONNX Runtime,GPU / Ascend 环境须关闭默认组。切换后端建议使用独立环境。`ascend` 是空的兼容 extra,不再安装厂商运行时。独立的 `requirements/ascend.txt` 按 Linux x86_64 / aarch64、CPython 3.10–3.12 选择官方 ACLRuntime / ais_bench 0.0.2 wheel;仅在这些环境执行,其他环境需自行准备兼容运行时。此文件中的平台条件在不支持的环境会跳过所有条目,并不表示该环境支持 Ascend。
|
|
66
|
+
|
|
67
|
+
当前版本为 **0.2.1**,变更和迁移说明见 [CHANGELOG](CHANGELOG.md)。发行工作流通过 [GitHub Releases](https://github.com/Jasper-T/ai-inference/releases) 提供 wheel、源码包及 `SHA256SUMS`;取得 wheel 并核对哈希后安装:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
uv venv --python 3.12
|
|
71
|
+
uv pip install './ai_inference-0.2.1-py3-none-any.whl[onnx-cpu]'
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
GPU 使用 `[onnx-gpu]`。Ascend 安装基础 wheel 后,还须从同版本源码包取得 `requirements/ascend.txt`,执行 `uv pip install -r requirements/ascend.txt`(或 `python -m pip install -r requirements/ascend.txt`)。GPU 运行时必须与 NVIDIA 驱动、CUDA、cuDNN 兼容,见 [CUDA 部署说明](docs/configuration.md#cuda-部署与失败)。
|
|
75
|
+
|
|
76
|
+
## 检测调用
|
|
77
|
+
|
|
78
|
+
准备本地模型文件和图片,修改 YAML 中的模型路径与类别配置:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
import cv2
|
|
82
|
+
from ai_inference import Model
|
|
83
|
+
|
|
84
|
+
model = Model("configs/yolo11.yaml")
|
|
85
|
+
image = cv2.imread("image.jpg") # HWC uint8;示例配置使用 BGR
|
|
86
|
+
if image is None:
|
|
87
|
+
raise FileNotFoundError("image.jpg")
|
|
88
|
+
|
|
89
|
+
result = model.predict(image)[0]
|
|
90
|
+
print(result.boxes, result.scores, result.class_ids)
|
|
91
|
+
results = model.predict([image, image]) # 与输入顺序一致
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
检测结果为 `list[Prediction]`,空输入返回空列表。框为 float32 `[K,4]` 原图像素 xyxy;分数为 `[K]`,类别 ID 为 int64,`original_shape` 为 `(H,W)`。可选关键点为 `[K,P,2]` 原图 xy,掩码为 `[K,H,W]`。
|
|
95
|
+
|
|
96
|
+
也可分步执行,`RawOutput` 携带当前请求的预处理元数据:
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
prepared = model.preprocess([image, image])
|
|
100
|
+
raw = model.infer(prepared)
|
|
101
|
+
results = model.postprocess(raw)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 人脸关键点与特征
|
|
105
|
+
|
|
106
|
+
YuNet 提供人脸框和五点关键点,SFace 根据五点对齐后提取特征:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from ai_inference import FaceInput, Model
|
|
110
|
+
|
|
111
|
+
detector = Model("configs/yunet.yaml")
|
|
112
|
+
encoder = Model("configs/sface.yaml")
|
|
113
|
+
faces = detector.predict(image)[0]
|
|
114
|
+
if len(faces.boxes):
|
|
115
|
+
feature = encoder.predict(FaceInput(image, faces.keypoints[0]))[0]
|
|
116
|
+
print(feature.embedding) # float32 [D],默认 L2 归一化
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
已经对齐的 112×112 裁剪须在 `face_align` 步骤中显式配置 `aligned_input: true`。人脸质量评估、人员关联和特征库检索由应用实现。模型输入契约见 [配置说明](docs/configuration.md#结果人脸输入与扩展模型契约)。
|
|
120
|
+
|
|
121
|
+
## 配置与失败行为
|
|
122
|
+
|
|
123
|
+
| 示例配置 | 模型契约 |
|
|
124
|
+
| --- | --- |
|
|
125
|
+
| [yolo11.yaml](configs/yolo11.yaml) | YOLO11n COCO,固定 batch=1 |
|
|
126
|
+
| [rfdetr.yaml](configs/rfdetr.yaml) | RF-DETR Nano COCO,384×384,固定 batch=1 |
|
|
127
|
+
| [rtdetr.yaml](configs/rtdetr.yaml) | 原始 RT-DETR deploy 导出,动态 batch 上限 2 |
|
|
128
|
+
| [yunet.yaml](configs/yunet.yaml) | YuNet 2023mar 五点检测,640×640 |
|
|
129
|
+
| [sface.yaml](configs/sface.yaml) | SFace 2021dec 特征提取 |
|
|
130
|
+
| [rfdetr_om.yaml](configs/rfdetr_om.yaml) | 官方 RF-DETR Nano 转换的静态 OM / AIPP |
|
|
131
|
+
|
|
132
|
+
ONNX 示例默认使用 CPU 和 BGR 图像。CPU / CUDA / TensorRT 共用模型契约,通过 `runtime.options.providers` 选择 `cpu`、`cuda`、`trt` 或有序列表 `[trt, cuda, cpu]`。单项严格使用指定后端;列表允许按序初始化降级和算子回退,执行失败直接抛错。
|
|
133
|
+
|
|
134
|
+
相对模型路径以 YAML 所在目录解析。ONNX / OM 自动读取真实输入输出的名称、dtype、shape,YAML 中的 `inputs` / `outputs` 可作为可选约束;预后处理步骤仍须显式配置并匹配模型契约。静态模型不能通过修改 YAML 变成动态模型。默认执行 3 次引擎 warmup,可用 `runtime.warmup` / `warmup_runs` 调整。
|
|
135
|
+
|
|
136
|
+
公开张量和内置前后处理使用 CPU NumPy。权重不随仓库分发,不自动下载;来源、哈希和许可由部署方核实。详细规则见 [配置与模型契约](docs/configuration.md)。
|
|
137
|
+
|
|
138
|
+
## 标注与批量示例
|
|
139
|
+
|
|
140
|
+
`Plotter` 只消费图像和既有结果,可独立绘制框、关键点和掩码:
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
from ai_inference import Plotter
|
|
144
|
+
|
|
145
|
+
Plotter().save("results/annotation.png", image, result, names={0: "person"})
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
类别名称只影响标注,未提供名称时显示原始 ID。默认不添加顶部标题或统计;可通过 `title`、`note`、`show_summary=True` 启用。
|
|
149
|
+
|
|
150
|
+
准备五个模型后,可对同一图片执行推理并保存 PNG / JSON:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
uv run --locked python scripts/predict_all.py --image tests/bus.jpg --results results
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
SFace 使用 YuNet 检测的五点;没有有效人脸时输出 `not_run` 状态。最小调用见 [examples](examples/README.md),完整场景工具见 [scripts](scripts/README.md)。
|
|
157
|
+
|
|
158
|
+
## 开发与验证
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
uv sync --locked --extra service
|
|
162
|
+
uv lock --check
|
|
163
|
+
uv run --locked --no-sync ruff check src tests scripts examples
|
|
164
|
+
uv run --locked --no-sync ruff format --check src tests scripts examples
|
|
165
|
+
uv run --locked --no-sync python scripts/test.py all
|
|
166
|
+
uv build
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
以上命令同时验证 SDK 和服务;只验证基础 SDK 时可不启用 `service` extra,服务测试会在缺少 HTTP 依赖时跳过。服务说明见 [HTTP 服务](docs/service/README.md)。新增运行依赖用 `uv add`,开发工具用 `uv add --dev`,测试依赖用 `uv add --group test`,并提交 `pyproject.toml` 和 `uv.lock`。
|
|
170
|
+
|
|
171
|
+
## 文档
|
|
172
|
+
|
|
173
|
+
- [CHANGELOG](CHANGELOG.md):版本变化与升级迁移。
|
|
174
|
+
- [模型下载](docs/model-downloads.md):各配置对应的官方权重、ONNX 文件与导出方式。
|
|
175
|
+
- [源码目录与职责](docs/architecture.md):组件职责与执行边界。
|
|
176
|
+
- [可组合处理管道](docs/pipeline.md):步骤、Context、几何信息与设备策略。
|
|
177
|
+
- [配置与模型契约](docs/configuration.md):张量、batch 和运行时选项。
|
|
178
|
+
- [处理器与扩展](docs/extension.md):自定义步骤、处理器、Engine 和 Predictor。
|
|
179
|
+
- [日志与性能测量](docs/logging-and-benchmark.md):日志上下文与 benchmark。
|
|
180
|
+
- [测试与复现](docs/testing.md):自动化测试、真实模型导出与参考对照。
|
|
181
|
+
- [发布工作流](docs/releases/actions.md):构建、发布与失败重试。
|
|
182
|
+
|
|
183
|
+
## 许可证
|
|
184
|
+
|
|
185
|
+
本项目采用 [MIT License](LICENSE)。第三方运行时和模型权重各自的许可须单独遵守。
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# ai-inference
|
|
2
|
+
|
|
3
|
+
通用 Python 模型推理 SDK,通过有序 Pipeline 执行前后处理,Engine 执行模型,Batcher 负责分批、补齐和结果合并。发行包名为 `ai-inference`,Python 导入名为 `ai_inference`。
|
|
4
|
+
|
|
5
|
+
支持 ONNX Runtime 和静态 Ascend OM,提供 RF-DETR、YOLOv8 / YOLO11、RT-DETR、YuNet 和 SFace 的处理步骤。检测结果可包含关键点和掩码;当前没有内置分割模型。HTTP 接口由可选的 [service](docs/service/README.md) 模块提供,与 SDK 使用同一发行包及版本;通过 `service` extra 安装 HTTP 依赖。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
Python >= 3.10。项目使用 [uv](https://docs.astral.sh/uv/) 管理依赖、环境、测试和构建。先安装 uv,再从仓库根目录运行:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# 开发环境:SDK、CPU ONNX Runtime、pytest、ONNX 和 Ruff
|
|
13
|
+
uv sync --locked
|
|
14
|
+
|
|
15
|
+
# CPU 运行环境,包括 macOS
|
|
16
|
+
uv sync --locked --no-default-groups --extra onnx-cpu
|
|
17
|
+
|
|
18
|
+
# NVIDIA Linux / Windows 运行环境
|
|
19
|
+
uv sync --locked --no-default-groups --extra onnx-gpu
|
|
20
|
+
|
|
21
|
+
# Ascend Linux 运行环境,CANN、驱动和设备环境须单独准备
|
|
22
|
+
uv sync --locked --python 3.12 --no-default-groups --extra ascend
|
|
23
|
+
uv pip install --python .venv/bin/python -r requirements/ascend.txt
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
需要 HTTP 服务时可组合安装:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install './ai_inference-0.2.1-py3-none-any.whl[service,onnx-cpu]'
|
|
30
|
+
# 在本仓库安装 CPU 服务运行环境
|
|
31
|
+
uv sync --locked --no-default-groups --extra service --extra onnx-cpu
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`0.2.1` 包含 `service` extra。上面的 wheel 命令在从 GitHub Release 下载制品后执行;新版本标签推送会发布 GitHub Release 并上传 PyPI,手动运行时也可选择仅 GitHub Release、TestPyPI 或 PyPI(需先配置 Trusted Publishing,见[发布说明](docs/releases/actions.md#通过-actions-上传-pypi))。包名安装要求对应版本存在于所用包索引。基础安装不引入 FastAPI/Uvicorn,服务代码包含在统一 wheel 中。
|
|
35
|
+
|
|
36
|
+
三个后端 extras 互斥。默认 dev/test 组包含 CPU ONNX Runtime,GPU / Ascend 环境须关闭默认组。切换后端建议使用独立环境。`ascend` 是空的兼容 extra,不再安装厂商运行时。独立的 `requirements/ascend.txt` 按 Linux x86_64 / aarch64、CPython 3.10–3.12 选择官方 ACLRuntime / ais_bench 0.0.2 wheel;仅在这些环境执行,其他环境需自行准备兼容运行时。此文件中的平台条件在不支持的环境会跳过所有条目,并不表示该环境支持 Ascend。
|
|
37
|
+
|
|
38
|
+
当前版本为 **0.2.1**,变更和迁移说明见 [CHANGELOG](CHANGELOG.md)。发行工作流通过 [GitHub Releases](https://github.com/Jasper-T/ai-inference/releases) 提供 wheel、源码包及 `SHA256SUMS`;取得 wheel 并核对哈希后安装:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
uv venv --python 3.12
|
|
42
|
+
uv pip install './ai_inference-0.2.1-py3-none-any.whl[onnx-cpu]'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
GPU 使用 `[onnx-gpu]`。Ascend 安装基础 wheel 后,还须从同版本源码包取得 `requirements/ascend.txt`,执行 `uv pip install -r requirements/ascend.txt`(或 `python -m pip install -r requirements/ascend.txt`)。GPU 运行时必须与 NVIDIA 驱动、CUDA、cuDNN 兼容,见 [CUDA 部署说明](docs/configuration.md#cuda-部署与失败)。
|
|
46
|
+
|
|
47
|
+
## 检测调用
|
|
48
|
+
|
|
49
|
+
准备本地模型文件和图片,修改 YAML 中的模型路径与类别配置:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import cv2
|
|
53
|
+
from ai_inference import Model
|
|
54
|
+
|
|
55
|
+
model = Model("configs/yolo11.yaml")
|
|
56
|
+
image = cv2.imread("image.jpg") # HWC uint8;示例配置使用 BGR
|
|
57
|
+
if image is None:
|
|
58
|
+
raise FileNotFoundError("image.jpg")
|
|
59
|
+
|
|
60
|
+
result = model.predict(image)[0]
|
|
61
|
+
print(result.boxes, result.scores, result.class_ids)
|
|
62
|
+
results = model.predict([image, image]) # 与输入顺序一致
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
检测结果为 `list[Prediction]`,空输入返回空列表。框为 float32 `[K,4]` 原图像素 xyxy;分数为 `[K]`,类别 ID 为 int64,`original_shape` 为 `(H,W)`。可选关键点为 `[K,P,2]` 原图 xy,掩码为 `[K,H,W]`。
|
|
66
|
+
|
|
67
|
+
也可分步执行,`RawOutput` 携带当前请求的预处理元数据:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
prepared = model.preprocess([image, image])
|
|
71
|
+
raw = model.infer(prepared)
|
|
72
|
+
results = model.postprocess(raw)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 人脸关键点与特征
|
|
76
|
+
|
|
77
|
+
YuNet 提供人脸框和五点关键点,SFace 根据五点对齐后提取特征:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from ai_inference import FaceInput, Model
|
|
81
|
+
|
|
82
|
+
detector = Model("configs/yunet.yaml")
|
|
83
|
+
encoder = Model("configs/sface.yaml")
|
|
84
|
+
faces = detector.predict(image)[0]
|
|
85
|
+
if len(faces.boxes):
|
|
86
|
+
feature = encoder.predict(FaceInput(image, faces.keypoints[0]))[0]
|
|
87
|
+
print(feature.embedding) # float32 [D],默认 L2 归一化
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
已经对齐的 112×112 裁剪须在 `face_align` 步骤中显式配置 `aligned_input: true`。人脸质量评估、人员关联和特征库检索由应用实现。模型输入契约见 [配置说明](docs/configuration.md#结果人脸输入与扩展模型契约)。
|
|
91
|
+
|
|
92
|
+
## 配置与失败行为
|
|
93
|
+
|
|
94
|
+
| 示例配置 | 模型契约 |
|
|
95
|
+
| --- | --- |
|
|
96
|
+
| [yolo11.yaml](configs/yolo11.yaml) | YOLO11n COCO,固定 batch=1 |
|
|
97
|
+
| [rfdetr.yaml](configs/rfdetr.yaml) | RF-DETR Nano COCO,384×384,固定 batch=1 |
|
|
98
|
+
| [rtdetr.yaml](configs/rtdetr.yaml) | 原始 RT-DETR deploy 导出,动态 batch 上限 2 |
|
|
99
|
+
| [yunet.yaml](configs/yunet.yaml) | YuNet 2023mar 五点检测,640×640 |
|
|
100
|
+
| [sface.yaml](configs/sface.yaml) | SFace 2021dec 特征提取 |
|
|
101
|
+
| [rfdetr_om.yaml](configs/rfdetr_om.yaml) | 官方 RF-DETR Nano 转换的静态 OM / AIPP |
|
|
102
|
+
|
|
103
|
+
ONNX 示例默认使用 CPU 和 BGR 图像。CPU / CUDA / TensorRT 共用模型契约,通过 `runtime.options.providers` 选择 `cpu`、`cuda`、`trt` 或有序列表 `[trt, cuda, cpu]`。单项严格使用指定后端;列表允许按序初始化降级和算子回退,执行失败直接抛错。
|
|
104
|
+
|
|
105
|
+
相对模型路径以 YAML 所在目录解析。ONNX / OM 自动读取真实输入输出的名称、dtype、shape,YAML 中的 `inputs` / `outputs` 可作为可选约束;预后处理步骤仍须显式配置并匹配模型契约。静态模型不能通过修改 YAML 变成动态模型。默认执行 3 次引擎 warmup,可用 `runtime.warmup` / `warmup_runs` 调整。
|
|
106
|
+
|
|
107
|
+
公开张量和内置前后处理使用 CPU NumPy。权重不随仓库分发,不自动下载;来源、哈希和许可由部署方核实。详细规则见 [配置与模型契约](docs/configuration.md)。
|
|
108
|
+
|
|
109
|
+
## 标注与批量示例
|
|
110
|
+
|
|
111
|
+
`Plotter` 只消费图像和既有结果,可独立绘制框、关键点和掩码:
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
from ai_inference import Plotter
|
|
115
|
+
|
|
116
|
+
Plotter().save("results/annotation.png", image, result, names={0: "person"})
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
类别名称只影响标注,未提供名称时显示原始 ID。默认不添加顶部标题或统计;可通过 `title`、`note`、`show_summary=True` 启用。
|
|
120
|
+
|
|
121
|
+
准备五个模型后,可对同一图片执行推理并保存 PNG / JSON:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
uv run --locked python scripts/predict_all.py --image tests/bus.jpg --results results
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
SFace 使用 YuNet 检测的五点;没有有效人脸时输出 `not_run` 状态。最小调用见 [examples](examples/README.md),完整场景工具见 [scripts](scripts/README.md)。
|
|
128
|
+
|
|
129
|
+
## 开发与验证
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
uv sync --locked --extra service
|
|
133
|
+
uv lock --check
|
|
134
|
+
uv run --locked --no-sync ruff check src tests scripts examples
|
|
135
|
+
uv run --locked --no-sync ruff format --check src tests scripts examples
|
|
136
|
+
uv run --locked --no-sync python scripts/test.py all
|
|
137
|
+
uv build
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
以上命令同时验证 SDK 和服务;只验证基础 SDK 时可不启用 `service` extra,服务测试会在缺少 HTTP 依赖时跳过。服务说明见 [HTTP 服务](docs/service/README.md)。新增运行依赖用 `uv add`,开发工具用 `uv add --dev`,测试依赖用 `uv add --group test`,并提交 `pyproject.toml` 和 `uv.lock`。
|
|
141
|
+
|
|
142
|
+
## 文档
|
|
143
|
+
|
|
144
|
+
- [CHANGELOG](CHANGELOG.md):版本变化与升级迁移。
|
|
145
|
+
- [模型下载](docs/model-downloads.md):各配置对应的官方权重、ONNX 文件与导出方式。
|
|
146
|
+
- [源码目录与职责](docs/architecture.md):组件职责与执行边界。
|
|
147
|
+
- [可组合处理管道](docs/pipeline.md):步骤、Context、几何信息与设备策略。
|
|
148
|
+
- [配置与模型契约](docs/configuration.md):张量、batch 和运行时选项。
|
|
149
|
+
- [处理器与扩展](docs/extension.md):自定义步骤、处理器、Engine 和 Predictor。
|
|
150
|
+
- [日志与性能测量](docs/logging-and-benchmark.md):日志上下文与 benchmark。
|
|
151
|
+
- [测试与复现](docs/testing.md):自动化测试、真实模型导出与参考对照。
|
|
152
|
+
- [发布工作流](docs/releases/actions.md):构建、发布与失败重试。
|
|
153
|
+
|
|
154
|
+
## 许可证
|
|
155
|
+
|
|
156
|
+
本项目采用 [MIT License](LICENSE)。第三方运行时和模型权重各自的许可须单独遵守。
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Official RF-DETR Nano COCO; 91 logit slots use sparse COCO category IDs.
|
|
2
|
+
model:
|
|
3
|
+
name: rfdetr_nano_coco
|
|
4
|
+
path: ../models/rfdetr-nano.onnx
|
|
5
|
+
runtime:
|
|
6
|
+
backend: onnxruntime
|
|
7
|
+
warmup: false
|
|
8
|
+
warmup_runs: 3
|
|
9
|
+
options:
|
|
10
|
+
providers: cpu
|
|
11
|
+
intra_op_num_threads: 1
|
|
12
|
+
batch:
|
|
13
|
+
mode: fixed
|
|
14
|
+
size: 1
|
|
15
|
+
padding: repeat_last
|
|
16
|
+
preprocess:
|
|
17
|
+
source_color: BGR
|
|
18
|
+
steps:
|
|
19
|
+
- resize:
|
|
20
|
+
width: 384
|
|
21
|
+
height: 384
|
|
22
|
+
- color:
|
|
23
|
+
source: BGR
|
|
24
|
+
target: RGB
|
|
25
|
+
- normalize:
|
|
26
|
+
divisor: 255
|
|
27
|
+
mean:
|
|
28
|
+
- 0.485
|
|
29
|
+
- 0.456
|
|
30
|
+
- 0.406
|
|
31
|
+
std:
|
|
32
|
+
- 0.229
|
|
33
|
+
- 0.224
|
|
34
|
+
- 0.225
|
|
35
|
+
- layout:
|
|
36
|
+
source: HWC
|
|
37
|
+
target: CHW
|
|
38
|
+
- pack:
|
|
39
|
+
input_name: input
|
|
40
|
+
postprocess:
|
|
41
|
+
steps:
|
|
42
|
+
- rfdetr_decode:
|
|
43
|
+
boxes_name: dets
|
|
44
|
+
logits_name: labels
|
|
45
|
+
threshold: 0.4
|
|
46
|
+
clip_boxes: true
|
|
47
|
+
integer_boxes: false
|
|
48
|
+
num_classes: 91
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Official RF-DETR Nano COCO converted to static OM with AIPP.
|
|
2
|
+
# Conversion must embed BGR-to-RGB and the ONNX normalization in static AIPP.
|
|
3
|
+
model:
|
|
4
|
+
name: rfdetr_nano_coco_aipp
|
|
5
|
+
path: ../models/rfdetr-nano.om
|
|
6
|
+
runtime:
|
|
7
|
+
backend: om
|
|
8
|
+
warmup: true
|
|
9
|
+
warmup_runs: 3
|
|
10
|
+
options:
|
|
11
|
+
device_id: 0
|
|
12
|
+
batch:
|
|
13
|
+
mode: fixed
|
|
14
|
+
size: 1
|
|
15
|
+
padding: repeat_last
|
|
16
|
+
preprocess:
|
|
17
|
+
source_color: BGR
|
|
18
|
+
steps:
|
|
19
|
+
- resize:
|
|
20
|
+
width: 384
|
|
21
|
+
height: 384
|
|
22
|
+
- pack:
|
|
23
|
+
input_name: input
|
|
24
|
+
postprocess:
|
|
25
|
+
steps:
|
|
26
|
+
- rfdetr_decode:
|
|
27
|
+
boxes_name: dets
|
|
28
|
+
logits_name: labels
|
|
29
|
+
threshold: 0.4
|
|
30
|
+
clip_boxes: true
|
|
31
|
+
integer_boxes: false
|
|
32
|
+
num_classes: 91
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
model:
|
|
2
|
+
name: rtdetr
|
|
3
|
+
path: ../models/rtdetr-deployed-v1.onnx
|
|
4
|
+
runtime:
|
|
5
|
+
backend: onnxruntime
|
|
6
|
+
warmup: false
|
|
7
|
+
warmup_runs: 3
|
|
8
|
+
batch:
|
|
9
|
+
mode: dynamic
|
|
10
|
+
size: 2
|
|
11
|
+
padding: repeat_last
|
|
12
|
+
options:
|
|
13
|
+
providers: cpu
|
|
14
|
+
intra_op_num_threads: 1
|
|
15
|
+
preprocess:
|
|
16
|
+
source_color: BGR
|
|
17
|
+
steps:
|
|
18
|
+
- color:
|
|
19
|
+
source: BGR
|
|
20
|
+
target: RGB
|
|
21
|
+
- resize:
|
|
22
|
+
width: 640
|
|
23
|
+
height: 640
|
|
24
|
+
backend: pillow
|
|
25
|
+
- normalize:
|
|
26
|
+
divisor: 255
|
|
27
|
+
- layout:
|
|
28
|
+
source: HWC
|
|
29
|
+
target: CHW
|
|
30
|
+
- pack:
|
|
31
|
+
input_name: images
|
|
32
|
+
sizes_name: orig_target_sizes
|
|
33
|
+
postprocess:
|
|
34
|
+
steps:
|
|
35
|
+
- rtdetr_decode:
|
|
36
|
+
threshold: 0.5
|
|
37
|
+
num_classes: 80
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
model:
|
|
2
|
+
name: sface_2021
|
|
3
|
+
path: ../models/face_recognition_sface_2021dec.onnx
|
|
4
|
+
runtime:
|
|
5
|
+
backend: onnxruntime
|
|
6
|
+
warmup: false
|
|
7
|
+
warmup_runs: 3
|
|
8
|
+
batch:
|
|
9
|
+
mode: fixed
|
|
10
|
+
size: 1
|
|
11
|
+
padding: repeat_last
|
|
12
|
+
options:
|
|
13
|
+
providers: cpu
|
|
14
|
+
intra_op_num_threads: 1
|
|
15
|
+
preprocess:
|
|
16
|
+
source_color: BGR
|
|
17
|
+
steps:
|
|
18
|
+
- face_align:
|
|
19
|
+
aligned_input: false
|
|
20
|
+
- color:
|
|
21
|
+
source: BGR
|
|
22
|
+
target: RGB
|
|
23
|
+
- cast:
|
|
24
|
+
dtype: float32
|
|
25
|
+
- layout:
|
|
26
|
+
source: HWC
|
|
27
|
+
target: CHW
|
|
28
|
+
- pack:
|
|
29
|
+
input_name: data
|
|
30
|
+
postprocess:
|
|
31
|
+
steps:
|
|
32
|
+
- sface_features:
|
|
33
|
+
output_name: fc1
|
|
34
|
+
dimensions: 128
|
|
35
|
+
- l2_normalize: {}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
model:
|
|
2
|
+
name: yolo11n_coco
|
|
3
|
+
path: ../models/yolo11n.onnx
|
|
4
|
+
runtime:
|
|
5
|
+
backend: onnxruntime
|
|
6
|
+
warmup: true
|
|
7
|
+
warmup_runs: 3
|
|
8
|
+
options:
|
|
9
|
+
providers: cpu
|
|
10
|
+
intra_op_num_threads: 1
|
|
11
|
+
batch:
|
|
12
|
+
mode: fixed
|
|
13
|
+
size: 1
|
|
14
|
+
padding: repeat_last
|
|
15
|
+
preprocess:
|
|
16
|
+
source_color: BGR
|
|
17
|
+
steps:
|
|
18
|
+
- resize:
|
|
19
|
+
width: 640
|
|
20
|
+
height: 640
|
|
21
|
+
keep_ratio: true
|
|
22
|
+
scale_up: true
|
|
23
|
+
- padding:
|
|
24
|
+
width: 640
|
|
25
|
+
height: 640
|
|
26
|
+
value: 114
|
|
27
|
+
alignment: center
|
|
28
|
+
- color:
|
|
29
|
+
source: BGR
|
|
30
|
+
target: RGB
|
|
31
|
+
- normalize:
|
|
32
|
+
divisor: 255
|
|
33
|
+
dtype: float32
|
|
34
|
+
- layout:
|
|
35
|
+
source: HWC
|
|
36
|
+
target: CHW
|
|
37
|
+
- pack:
|
|
38
|
+
input_name: images
|
|
39
|
+
postprocess:
|
|
40
|
+
steps:
|
|
41
|
+
- yolo_decode:
|
|
42
|
+
layout: NCQ
|
|
43
|
+
confidence_threshold: 0.25
|
|
44
|
+
iou_threshold: 0.7
|
|
45
|
+
max_detections: 300
|
|
46
|
+
max_nms: 30000
|
|
47
|
+
agnostic_nms: false
|
|
48
|
+
clip_boxes: true
|
|
49
|
+
num_classes: 80
|