v2.1.1 - Add stride-aware image profiling (#149)
🌟 Summary
🚀 THOP v2.1.1 adds stride-aware image profiling, enabling faster and more reliable MAC estimates for image models while modernizing benchmarks and documentation.
📊 Key Changes
- Stride-aware
profile()support by @glenn-jocher:- Adds an optional
strideargument for image models. - Profiles smaller, stride-aligned inputs instead of always processing the full target image.
- Uses one profile for spatial-only models and two profiles when fixed-cost layers—such as linear or adaptive pooling layers—require more accurate estimation.
- Falls back to the original target input if proxy inputs are unsupported or unsuitable.
- Existing calls such as
profile(model, inputs=...)remain unchanged.
- Adds an optional
- Simplified Ultralytics integration:
- Removes the need for Ultralytics-side image-size scaling and layer-inspection logic.
- Moves profiling behavior into THOP, the component that owns the operation-counting process.
- Preserves compatibility with YOLOv3, YOLOv5, and third-party users of the existing API.
- Version update:
- Bumps THOP to 2.1.1 and
ultralytics-thopfrom 2.1.0 to 2.1.1.
- Bumps THOP to 2.1.1 and
- Modernized benchmarks:
- Replaces legacy torchvision benchmark tables with fused YOLOv8, YOLO11, and YOLO26 results.
- Updates the benchmark script to reproduce 15 model variants at 640 × 640 without downloading weights.
- Improved documentation:
- Simplifies the English README with clearer installation and usage examples.
- Adds a Simplified Chinese README.
- Documents the new
strideprofiling workflow and custom operation rules.
- Repository workflow updates:
- Refreshes
AGENTS.mdwith stronger guidance around minimal changes, solving problems in the owning code path, deleting duplication, and avoiding regressions.
- Refreshes
- Validation:
- All 20 tests passed, with Ruff checks and formatting completed successfully ✅
🎯 Purpose & Impact
- ⚡ Faster profiling: Large image models can be analyzed using much smaller stride-aligned inputs, reducing profiling overhead.
- 🎯 More accurate estimates: Two-point profiling improves results for models that combine spatially scaling operations with fixed-cost layers.
- 🧩 Less duplicated code: Consumers no longer need to maintain their own FLOPs scaling and fallback policies.
- 🔒 Better compatibility: The new behavior is opt-in, so existing applications should continue to produce the same results when
strideis omitted. - 📈 More relevant comparisons: Updated YOLOv8, YOLO11, and YOLO26 benchmarks make it easier to compare modern Ultralytics model complexity before training or deployment.
- 🌍 Broader accessibility: Clearer documentation and Chinese-language support make THOP easier to adopt for a wider developer community.
What's Changed
- Refresh README and YOLO benchmarks by @glenn-jocher in #142
- Add stride-aware image profiling by @glenn-jocher in #149
Full Changelog: v2.1.0...v2.1.1