8000 Improve exporting process for AHOY with OBB models by kevinconka · Pull Request #21 · SEA-AI/yolov5 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve exporting process for AHOY with OBB models #21

New issue

Have a question about this project? Sign up for a free GitHub acc 10000 ount to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 10, 2025

Conversation

kevinconka
Copy link
@kevinconka kevinconka commented May 29, 2025

What?

Refactored the model export process to ensure the ONNX graph retains all simplifications implemented in the original ultralytics repository.

Also, new naming convention:
-AHOY --> AHOYv1
-AHOYOBB --> AHOYv2

saiyan2evolcution

Tip

You can still use AHOY(obj_det_weigths="", hor_det_weigths="", ...); the correct version will be selected automatically based on the provided weights 🤞

Why?

Addressed these key issues in the export pipeline:

  1. Residual gradient outputs: the OBBModel was still producing gradient tensors (ignored via post-processing hook).
  2. Model-specific pre-export steps: both YOLOv8 and YOLO11 require their own sequence of tensor adjustments before export which are a bit different from YOLOv5.
  3. Architectural insights mixed with naming.

Note

There is nothing wrong with AHOYOBB, but… what if in the future we do both object and horizon detection with OBB models? Would we call it AHOYOBBOBB or AHOYOBB²?

A more conventional naming scheme (a.k.a. AHOYv*) could help keep architectural insights and naming separate. You don’t see names like YOLOAnchorless or YOLOFlashAttention, those details are captured in documentation or model cards, not embedded in the name. Following that spirit keeps names clean and evolution-friendly.

How

  1. Switched from logging to LOGGER for unified logging
  2. Added prepare_for_export() to centralize export logic in model classes
  3. Create an AHOY base class and subclasses for AHOYv1 and AHOYv2.

Backout plan

The changes improve the exporting, they should not be reverted.

Testing

W&B integration

$ python3 export_ahoy.py -dw YOLOv5n6-MIX:latest -hw YOLO11n-OBBh:latest -sz 576 1920 -bs 1 --half --fuse -f /Users/kevinserrano/Downloads/ahoy-obb-MIX-576x1920.onnx
🚀 SEA.AI custom version
wandb:   1 of 1 files downloaded.  
wandb:   1 of 1 files downloaded.  
YOLOv5 🚀 v7.0-496-g0c1db812 Python-3.12.8 torch-2.5.1 CPU

Fusing layers... 
Model summary: 206 layers, 3104644 parameters, 0 gradients, 4.3 GFLOPs
Loaded weights from artifacts/YOLOv5n6-MIX:latest/best.pt
YOLOv5 🚀 v7.0-496-g0c1db812 Python-3.12.8 torch-2.5.1 CPU

Loaded weights from artifacts/YOLO11n-OBBh:latest/best.pt
YOLO11n-obb summary (fused): 109 layers, 2,653,918 parameters, 0 gradients, 6.6 GFLOPs
🚀 Exporting model AHOYv2 to /Users/kevinserrano/Downloads/ahoy-obb-MIX-576x1920.onnx...
✨ Preparing ObjectsModel for export...
✨ Preparing OBBModel for export...
🔮 Dummy input...torch.Size([1, 3, 576, 1920]), torch.uint8

ONNX: starting export with onnx 1.17.0...
...
ONNX: export success ✅ 7.0s, saved as /Users/kevinserrano/Downloads/ahoy-obb-MIX-576x1920.onnx (11.8 MB)
🎉 Model successfully exported to /Users/kevinserrano/Downloads/ahoy-obb-MIX-576x1920.onnx! 🚀

Before

image

After

image

kevinconka added 10 commits May 29, 2025 14:16
…re proper handling of weights path as a string.
…onsistency in error handling and status messages.
…e better results. A few simplifcations added as well.
…g AHOYv1 and AHOYv2 classes for better model management. Update export functions to accommodate these changes and enhance model export preparation.
…ormat and clipping. Adjust padding calculations for bounding boxes based on the new parameters.
…padding alongside the transformation. Update scaling logic in AHOYv1 and AHOYv2 classes to utilize the new ratio padding for accurate bounding box adjustments after transformations. Change interpolation method from NEAREST to BILINEAR for improved image quality.
Copy link
@Zwicii Zwicii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@kevinconka kevinconka merged commit d2b13a0 into develop Jun 10, 2025
1 check passed
@kevinconka kevinconka deleted the feature/improve-export-ahoy branch June 10, 2025 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0