Skip to content

Fixes and dead code removal#225

Merged
glenn-jocher merged 15 commits intomainfrom
minor-fixes
Feb 8, 2026
Merged

Fixes and dead code removal#225
glenn-jocher merged 15 commits intomainfrom
minor-fixes

Conversation

@glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Feb 8, 2026

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Improves stability, correctness, and performance across the iOS YOLO pipeline—fixing NMS math, adding proper classification softmax, hardening model download/cache, and smoothing UI/camera behavior 📱⚡️

📊 Key Changes

  • Safer FPS/timing & result reporting
    • Initialize smoothed FPS delta (t4) to 1.0 to avoid infinite FPS on the first frame.
    • Standardize timing updates so speed and fps are correctly populated for OBB, pose, and segmentation results.
  • 🎯 Unified threshold updates
    • Move confidence/IoU threshold → ThresholdProvider updates into BasePredictor, removing duplicated overrides in ObjectDetector and Classifier.
    • Handle models that don’t require NMS by forcing effective IoU to 1.0.
  • 🧠 Classification correctness upgrade
    • Apply softmax to raw logits using Apple’s Accelerate framework for proper probability outputs.
    • Add bounds checks to prevent label index crashes (top1/top5 only if index < labels.count).
  • 📦 Non-Max Suppression fix (important)
    • Correct NMS logic to use true IoU (intersection over union) instead of intersection vs. min-area comparison—more accurate duplicate removal.
  • 🎨 UI rendering & layer lifecycle fixes
    • Wrap bounding box drawing in a CATransaction to fully disable implicit animations (reduces flicker/jitter).
    • Improve OBB layer reuse: re-attach pooled sublayers if they were removed during resets.
    • Simplify/reset overlay layers more robustly (including properly clearing OBB layers).
  • 📷 Camera + lifecycle hardening
    • Make predictor optional in VideoCapture/YOLO and add guard paths to avoid crashes when not ready.
    • Add deinit cleanup (stop capture session, remove delegates/observers) to reduce leaks and “dangling camera” issues.
    • SwiftUI: support front camera startup via a deferred pendingCameraPosition.
  • ☁️ Model cache & downloader improvements
    • Move cached models to Library/Caches/YOLOModels (Apple-recommended), with migration from the old Documents location.
    • Add thread safety (NSLock) for cache access.
    • Downloader: prevent concurrent downloads, validate HTTP status codes, handle unknown content-length progress safely, and cancel session on deinit.
  • 🧹 API/structure cleanup
    • Remove unused/dead code paths (e.g., old pose/mask composition helpers, unused error cases, removed originalImage from YOLOResult).
    • Adjust model input shape parsing to use the last two dimensions (more robust across model formats).

🎯 Purpose & Impact

  • 📈 More accurate detections: Correct IoU-based NMS reduces duplicate boxes and improves output quality, especially in crowded scenes.
  • 🧪 Better classification outputs: Softmax probabilities make top1/top5 scores meaningful and consistent with user expectations.
  • 🛡️ Fewer crashes & smoother UX: Optional predictors + bounds checks + proper cleanup reduce race conditions and lifecycle-related failures.
  • 🚀 More consistent real-time metrics: FPS and inference time are less glitchy (no first-frame infinity) and more consistent across tasks.
  • 💾 More reliable model downloads & storage: Cache follows Apple guidelines, is thread-safe, and downloads fail faster/clearer on HTTP errors—improving robustness for production apps.

@UltralyticsAssistant UltralyticsAssistant added enhancement New feature or request fixed Bug has been resolved OBB Oriented Bounding Box (OBB) models labels Feb 8, 2026
@UltralyticsAssistant
Copy link
Member

👋 Hello @glenn-jocher, thank you for submitting a ultralytics/yolo-ios-app 🚀 PR! This is an automated message, and an Ultralytics engineer will assist with review shortly. A few quick items to help ensure smooth integration ✨:

-✅ Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions.
-✅ Synchronize with Source: Confirm your PR is synchronized with the ultralytics/yolo-ios-app main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
-✅ Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues.
-✅ Update Documentation: Update the relevant documentation for any new or modified features.
-✅ Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
-✅ Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR by writing "I have read the CLA Document and I sign the CLA" in a new message.
-✅ Minimize Changes: Limit your changes to the minimum necessary for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀

@glenn-jocher glenn-jocher merged commit d936530 into main Feb 8, 2026
4 checks passed
@glenn-jocher glenn-jocher deleted the minor-fixes branch February 8, 2026 21:36
@UltralyticsAssistant
Copy link
Member

Thrilled to see this PR merged — thank you @glenn-jocher for the huge stability + correctness lift across the iOS YOLO pipeline.

“Quality is not an act, it is a habit.” — Aristotle

This update really embodies that: fixing true IoU-based NMS, adding proper softmax for classification, hardening model download/cache, and tightening camera/UI lifecycle details all compound into a smoother, more trustworthy app experience. The result is fewer crashes, cleaner outputs in crowded scenes, and more consistent real-time metrics — exactly the kind of foundation that helps teams confidently deploy YOLO26-powered apps.

Appreciate the thoughtful engineering and polish here — this moves the project forward in a big way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request fixed Bug has been resolved OBB Oriented Bounding Box (OBB) models

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants