Skip to content

v2.1.1 - Add stride-aware image profiling (#149)

Choose a tag to compare

@github-actions github-actions released this 28 Jul 15:00
· 32 commits to main since this release
163c085

🌟 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 stride argument 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.
  • 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-thop from 2.1.0 to 2.1.1.
  • 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 stride profiling workflow and custom operation rules.
  • Repository workflow updates:
    • Refreshes AGENTS.md with stronger guidance around minimal changes, solving problems in the owning code path, deleting duplication, and avoiding regressions.
  • 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 stride is 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

Full Changelog: v2.1.0...v2.1.1