Skip to content

feat(yolox): add YOLOX object detection - #1285

Draft
wyh88 wants to merge 3 commits into
NVIDIA:mainfrom
wyh88:feat/yolox-s
Draft

wyh88 wants to merge 3 commits into
NVIDIA:mainfrom
wyh88:feat/yolox-s

Conversation

@wyh88

@wyh88 wyh88 commented Sep 13, 2026

Copy link
Copy Markdown

Background

Add YOLOX-s object detection using the official Megvii checkpoint. This follows the family layout and native detection interface used by YOLOv8 (#1258) and YOLO11 (#1265).

Exit Criteria

  • Build and run nano, tiny, s, m, l, x and Darknet53 checkpoints.
  • Infer convolution channels and CSP/residual block counts from the weights.
  • Match the official reference on landscape and portrait inputs using the existing tolerances.

Scope is the published 80-class models, batch one. Nano and tiny use 416 x 416; the other models use 640 x 640.

Implementation

Adds families/yolox/ with checkpoint loading, TensorRT graphs, native preprocessing and class-aware NMS. Nano uses depthwise separable convolutions. Darknet53 uses its own backbone, FPN and LeakyReLU. A model directory contains one official checkpoint.

The graph decodes boxes at strides 8, 16 and 32, multiplying objectness by class probability. Runtime preprocessing follows YOLOX's BGR byte input and top-left letterbox padding. Runtime shape checks account for both supported input sizes.

FP16 builds keep the stem, neck, head, SiLU arithmetic and depthwise/pointwise pairs with their CSP residual paths in FP32. Keeping those pairs in FP32 prevents accumulated score error in nano. Test tolerances are unchanged.

Each model has one FP16 manifest. Release-performance profiles are explicitly excluded until benchmark workloads and measurements are available. The public build/detection API and bundle schema are unchanged. PyTorch reads state dictionaries with weights_only=True; the other family requirements support the official reference tests.

Change categories

  • Model or runtime behavior
  • Dependencies
  • CI or developer tooling

Validation

Commands and Results

All seven FP16 engines were built and tested against the official reference. Both image geometries passed raw-output and final-detection checks. The current native runtime was then replayed for all 14 model/image combinations:

Model Network size Detections (landscape / portrait) Max score error Max box error (original px) Min box IoU
yolox-nano 416 1 / 2 0.001354 0.3852 0.997407
yolox-tiny 416 1 / 1 0.000673 0.4100 0.997901
yolox-s 640 1 / 1 0.000176 0.0229 0.999829
yolox-m 640 1 / 1 0.000019 0.0076 0.999920
yolox-l 640 1 / 1 0.000047 0.0131 0.999943
yolox-x 640 1 / 1 0.000012 0.0088 0.999949
yolox-darknet 640 1 / 1 0.000056 0.0388 0.999711

Errors above are maxima across the two inputs after NMS; boxes are in original image pixels. Native and reference detection counts and classes matched in every comparison.

Local checks:

  • python -m tools.model_ci validate: passed.
  • python -m tools.community_ci source-quality --base 474c50e7: passed, 166 tests.
  • python -m pytest apps/benchmark/trtmc_benchmark/tests/test_perf_matrix.py -q -p no:cacheprovider: 43 passed.
  • Family unit tests: 30 CPU tests and one GPU SiLU regression passed.
  • Native YOLOX build and preprocessing/NMS CTest: passed.
  • From website/, SITE_URL=https://nvidia.github.io BASE_URL=/TensorRT-Model-Connect/ npm run build: passed, including 34 SVG checks; dependencies installed with npm ci from the lockfile.

Hardware, Environment, and Revisions

  • Tested source: the all-variant changes on top of 8500bae2 in this PR branch.
  • RTX 4070 Ti SUPER 16 GB, Ubuntu 24.04 under WSL2.
  • Python 3.12.3, PyTorch 2.12.0+cu130, TensorRT 11.1.0.106, CUDA toolkit 12.6, OpenCV 5.0.0.
  • Node.js 20.20.2, Docusaurus 3.10.2.
  • Official weights from release 0.1.1rc0; the unmodified reference revision is pinned in families/yolox/tests/reference-source.json.

Not Run / Remaining Gaps

  • GitHub CI must run after this update is pushed. These are local results.
  • COCO mAP, latency, throughput, other GPUs and an FP32 sweep of all variants were not measured. The two image geometries use the same photograph.
  • The full repository CPU suite was not rerun for this update.

Contributor Self-Review

  • I have completed a self-review of this change.

Pending before marking the draft ready.

Notes For Future Readers

Start with model.py, then the native runtime and tests/test_e2e.py. The model topology and checkpoints come from Megvii's official YOLOX repository. The seven manifests drive the generated model-support documentation.

Risk level

  • Medium

This adds a model family with two backbone architectures and mixed precision. Current GPU validation covers one device and two image geometries.

Signed-off-by: wyh88 <2469410854@qq.com>
@coderabbitai

coderabbitai Bot commented Sep 13, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: wyh88 <2469410854@qq.com>
@wyh88 wyh88 changed the title feat(yolox): add YOLOX-s object detection feat(yolox): add YOLOX object detection Sep 13, 2026
Signed-off-by: wyh88 <2469410854@qq.com>
@yifeif-nv

Copy link
Copy Markdown
Collaborator

Hey @wyh88 thanks for the contribution. The PR looks good and I'm triggering the internal CI for you! Let's see how it goes

@yifeif-nv yifeif-nv added run-internal-ci Maintainer-approved dispatch to internal CI and removed run-internal-ci Maintainer-approved dispatch to internal CI labels Sep 14, 2026
@yifeif-nv yifeif-nv closed this Sep 14, 2026
@yifeif-nv yifeif-nv reopened this Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-internal-ci Maintainer-approved dispatch to internal CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants