Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account 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

Feat/ultralytics obb support #4230

Merged
merged 2 commits into from Apr 5, 2024

Conversation

dimidagd
Copy link
Contributor

@dimidagd dimidagd commented Apr 4, 2024

  • Add YoloOBB class adapter
  • Use obb attribute from OBB ultralytics model outputs to create 51 polyline label.

What changes are proposed in this pull request?

Model outputs from OBB ultralytics models were ignored. This commit enables use of apply_model method on a 51 dataset.

import fiftyone as fo
import fiftyone.zoo as foz
from ultralytics import YOLO

model = YOLO('yolov8n-obb.pt')
dataset = foz.load_zoo_dataset(
    'coco-2017',
    split='validation',
)
fo.apply_model(dataset, model)

(Details)

Release Notes

Is this a user-facing change that should be mentioned in the release notes?

  • [] No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release
    notes for FiftyOne users.

(Details in 1-2 sentences. You can just refer to another PR with a description
if this PR is part of a larger change.)

What areas of FiftyOne does this PR affect?

  • App: FiftyOne application changes
  • Build: Build and test infrastructure changes
  • Core: Core fiftyone Python library changes
  • Documentation: FiftyOne documentation changes
  • Other

Summary by CodeRabbit

  • New Features
    • Introduced functionality to convert Ultralytics YOLO instance segmentations to FiftyOne format.
    • Added support for YOLO OBB detection models, including configuration and model handling enhancements.

- Add YoloOBB class adapter
- Use obb attribute from OBB ultralytics model outputs to create 51 polyline label.
Copy link
Contributor

coderabbitai bot commented Apr 4, 2024

Walkthrough

The recent update introduces functionality to handle Oriented Bounding Box (OBB) models from Ultralytics YOLO within the FiftyOne toolkit. It adds a specific function for converting YOLO instance segmentations to the FiftyOne format, alongside new classes designed for managing YOLO OBB detection models. Additionally, it updates the conversion logic to support these OBB models, enhancing the toolkit's versatility in object detection tasks.

Changes

File Path Change Summary
fiftyone/utils/ultralytics.py - Added obb_to_polylines function.
- Added FiftyOneYOLOOBBConfig and FiftyOneYOLOOBBModel classes.
- Updated convert_ultralytics_model to support YOLO OBB models.

Possibly related issues

Poem

In the digital fields where the codebunnies play,
A new feature blooms, oh what a day!
🐰💻 With bounding boxes, oriented and neat,
Our YOLO detections are now complete.
Across the FiftyOne land, under the silicon sun,
We hop with joy, for our task is done.
🌟✨ To the future, we leap, with code so bright,
In the world of AI, we bring new light.

Warning

Following problems were encountered

  • Git: Failed to clone repository. Please contact CodeRabbit support.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 8c8505d and e22ce44.
Files selected for processing (1)
  • fiftyone/utils/ultralytics.py (4 hunks)
Additional comments not posted (4)
fiftyone/utils/ultralytics.py (4)

45-48: Consider adding a brief docstring to the _convert_yolo_obb_model function to explain its purpose and usage.


172-222: Ensure that the obb_to_polylines function correctly handles the conversion of OBB detections to polylines, especially the transformation of coordinates from the OBB format to the polyline format. Verify that the points variable is correctly populated with the expected format for polylines in FiftyOne.

#!/bin/bash
# Verify the coordinate transformation logic by checking for unit tests or examples that use `obb_to_polylines`.
fd --type f --exec grep -Hn 'obb_to_polylines' {} +

440-458: Ensure that the FiftyOneYOLOOBBModel class's _format_predictions method correctly converts predictions to the expected format for FiftyOne. This is crucial for integrating OBB detections into the FiftyOne ecosystem seamlessly.

#!/bin/bash
# Check for usage examples or tests for `FiftyOneYOLOOBBModel` to ensure correct prediction formatting.
fd --type f --exec grep -Hn 'FiftyOneYOLOOBBModel' {} +

505-507: The _convert_yolo_obb_model function correctly creates a configuration for the OBB model and returns an instance of FiftyOneYOLOOBBModel. Ensure that this function is properly integrated and used wherever Ultralytics YOLO OBB models need to be converted for use in FiftyOne.

@jacobmarks jacobmarks self-requested a review April 5, 2024 00:28
Copy link
Contributor

@jacobmarks jacobmarks left a comment

Choose a reason for hiding this comment

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

Overall this implementation looks solid to me, and it works! Noting that the OBB models from Ultralytics are trained on DOTA so don't really work on datasets like COCO :)

Awesome contribution @dimidagd 💪

If you're so inclined, also feel free to add these pretrained OBB models to the FiftyOne Model Zoo, so that downloading and location of checkpoint is managed by FiftyOne :) You can do so by adding them here. In addition, you can add a section to the Ultralytics integration docs inference section for OBB object detection.

All that being said, if you don't have the time, we can also make sure these get in, so as to highlight the awesomeness of your work!!!

Copy link

codecov bot commented Apr 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 28.23%. Comparing base (fde69bc) to head (e22ce44).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4230   +/-   ##
========================================
  Coverage    28.23%   28.23%           
========================================
  Files          813      813           
  Lines       101849   101849           
  Branches      1214     1214           
========================================
  Hits         28761    28761           
  Misses       73088    73088           
Flag Coverage Δ
app 15.74% <ø> (ø)
python 99.24% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jacobmarks jacobmarks merged commit 4277d83 into voxel51:develop Apr 5, 2024
9 of 10 checks passed
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.

None yet

2 participants