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

YOLOv8 classification format #8475

Merged
merged 13 commits into from
Oct 7, 2024
Merged

YOLOv8 classification format #8475

merged 13 commits into from
Oct 7, 2024

Conversation

Eldies
Copy link
Contributor

@Eldies Eldies commented Sep 26, 2024

Motivation and context

Supporting YOLOv8 classification format

How has this been tested?

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • I have linked related issues (see GitHub docs)
  • I have increased versions of npm packages if it is necessary
    (cvat-canvas,
    cvat-core,
    cvat-data and
    cvat-ui)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

Summary by CodeRabbit

  • New Features

    • Added support for the "YOLOv8 Classification" format in the application, including export and import functionalities.
    • Updated documentation to include details about the new YOLOv8 Classification format.
  • Bug Fixes

    • Enhanced test coverage for the new YOLOv8 Classification format to ensure proper functionality in export and import processes.
  • Documentation

    • Integrated new entries in the README and detailed documentation for the YOLOv8 Classification format.

Copy link
Contributor

coderabbitai bot commented Sep 26, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce support for the "YOLOv8 Classification" format across various components of the CVAT application. The README.md file is updated to include this new format, while the functionality for exporting and importing YOLOv8 classification data is implemented in the yolo.py file. Additionally, test cases are modified to account for this new format, and documentation is added to describe its specifications and usage.

Changes

Files Change Summary
README.md Added "YOLOv8 Classification" format to the supported formats table.
cvat/apps/dataset_manager/formats/yolo.py Introduced _export_yolov8_classification and _import_yolov8_classification functions.
cvat/apps/dataset_manager/tests/assets/annotations.json Added new entry for "YOLOv8 Classification 1.0" with version and tag properties.
cvat/apps/dataset_manager/tests/test_formats.py Updated tests to include "YOLOv8 Classification 1.0" in export/import queries and checks.
cvat/apps/dataset_manager/tests/test_rest_api_formats.py Added "YOLOv8 Classification 1.0" to multiple relevant test cases for API format support.
cvat/requirements/base.in Updated datumaro dependency to a new commit reference.
cvat/requirements/base.txt Updated datumaro dependency to a new commit reference.
site/content/en/docs/manual/advanced/formats/_index.md Added "YOLOv8 Classification 1.0" entry to documentation for data export formats.
site/content/en/docs/manual/advanced/formats/format-yolov8-classification.md Created documentation for the YOLOv8 Classification format detailing export/import processes.

Poem

In the meadow where data flows,
A new format for classification grows.
YOLOv8 hops in with joy so bright,
With tags and images, a splendid sight!
Let’s celebrate this change today,
For bunnies and data, hip-hip-hooray! 🐇✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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/schema.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

🧹 Outside diff range and nitpick comments (8)
site/content/en/docs/manual/advanced/formats/format-yolov8-classification.md (3)

8-11: LGTM: Useful references provided. Consider adding brief descriptions.

The links to the format specification and dataset examples are valuable. To enhance user understanding, consider adding a brief description of what each link contains.

Example improvement:

- [Format specification](https://docs.ultralytics.com/datasets/classify/) - Detailed YOLOv8 Classification format guidelines
- [Dataset examples](https://github.com/cvat-ai/datumaro/tree/develop/tests/assets/yolo_dataset/yolov8_classification) - Sample datasets in YOLOv8 Classification format

13-20: LGTM: Export details are clear. Consider adding import information.

The export details are well-explained, clearly stating what is and isn't supported.

Consider adding a brief section about import support, if applicable. For example:

## YOLOv8 Classification import

- Supported annotations: Tags.
- Attributes: Not supported.
- Tracks: Not supported.

This would provide a complete picture of both export and import capabilities for this format.


21-39: LGTM: Archive structure is well-documented. Consider adding a note about multiple labels.

The archive structure is clearly explained and visualized. The inclusion of information about the optional labels.json file is helpful.

Consider adding a note to clarify how images with multiple labels are handled. For example:

Note: If an image has multiple labels, it will be duplicated and placed in each corresponding label directory.

This would help users understand how the export handles more complex annotation scenarios.

cvat/apps/dataset_manager/formats/yolo.py (2)

105-107: LGTM! Consider adding a brief docstring.

The implementation of _export_yolov8_classification is consistent with other YOLO export functions in the file. It correctly uses the @exporter decorator and calls _export_common with the appropriate format name.

Consider adding a brief docstring to explain the purpose of this function and any specific details about the YOLOv8 classification format. For example:

@exporter(name='YOLOv8 Classification', ext='ZIP', version='1.0')
def _export_yolov8_classification(*args, **kwargs):
    """
    Export annotations in YOLOv8 classification format.
    This format is used for image classification tasks in YOLOv8.
    """
    _export_common(*args, format_name='yolov8_classification', **kwargs)

144-146: LGTM! Consider adding a brief docstring.

The implementation of _import_yolov8_classification is consistent with other YOLO import functions in the file. It correctly uses the @importer decorator and calls _import_common with the appropriate format name.

Consider adding a brief docstring to explain the purpose of this function and any specific details about importing the YOLOv8 classification format. For example:

@importer(name='YOLOv8 Classification', ext="ZIP", version="1.0")
def _import_yolov8_classification(*args, **kwargs):
    """
    Import annotations from YOLOv8 classification format.
    This function handles the import of image classification data used in YOLOv8.
    """
    _import_common(*args, format_name="yolov8_classification", **kwargs)
site/content/en/docs/manual/advanced/formats/_index.md (1)

53-53: LGTM! Consider adding a link to the YOLOv8 Classification documentation.

The new entry for YOLOv8 Classification 1.0 is correctly formatted and consistent with other entries in the table. It provides appropriate information for a classification format.

Consider adding a link to the YOLOv8 Classification documentation in the format name, similar to other entries in the table. This would improve consistency and user experience. You can do this by wrapping the format name in a link, like this:

| [YOLOv8 Classification 1.0](format-yolov8-classification) | .jpg | Classification | YOLOv8 | Tags | No attributes | Not supported |
README.md (1)

179-182: LGTM! Consider adding a changelog entry.

The addition of the YOLOv8 Classification format to the supported annotation formats table is consistent with the existing entries and enhances the comprehensiveness of the list. The provided link is correct and the import/export support is clearly indicated.

Consider adding an entry to the changelog (if not already done) to highlight this new supported format for users upgrading or looking for recent changes.

cvat/apps/dataset_manager/tests/test_formats.py (1)

384-384: LGTM: YOLOv8 Classification format added to empty image export test

The addition of ('YOLOv8 Classification 1.0', 'yolov8_classification') to the test cases for empty image export is appropriate and consistent with other format tests.

Consider adding a comment explaining the purpose of this test case, similar to the comments for other formats (e.g., "# ('KITTI 1.0', 'kitti') format does not support empty annotations"). This would improve code readability and maintainability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 45d2d01 and c6a392a.

📒 Files selected for processing (9)
  • README.md (1 hunks)
  • cvat/apps/dataset_manager/formats/yolo.py (2 hunks)
  • cvat/apps/dataset_manager/tests/assets/annotations.json (1 hunks)
  • cvat/apps/dataset_manager/tests/test_formats.py (3 hunks)
  • cvat/apps/dataset_manager/tests/test_rest_api_formats.py (5 hunks)
  • cvat/requirements/base.in (1 hunks)
  • cvat/requirements/base.txt (1 hunks)
  • site/content/en/docs/manual/advanced/formats/_index.md (2 hunks)
  • site/content/en/docs/manual/advanced/formats/format-yolov8-classification.md (1 hunks)
🔇 Additional comments (14)
site/content/en/docs/manual/advanced/formats/format-yolov8-classification.md (2)

1-6: LGTM: Metadata section is well-structured and informative.

The metadata section provides clear and accurate information about the document's content and purpose.


1-39: Overall, excellent documentation for YOLOv8 Classification format.

This new file provides clear, concise, and well-structured documentation for the YOLOv8 Classification format in CVAT. It covers the essential aspects of export functionality and archive structure, making it easier for users to understand and work with this format.

The suggested improvements are minor and aim to enhance clarity and completeness:

  1. Adding brief descriptions to the reference links
  2. Including import information if applicable
  3. Clarifying how images with multiple labels are handled in the export

Great job on creating this comprehensive documentation!

cvat/requirements/base.in (1)

15-15: Verify the purpose and impact of updating the datumaro package.

The commit hash for the datumaro package has been updated. This change might introduce new features, bug fixes, or changes in behavior that could affect the project.

  1. Could you please clarify if this update is related to supporting the YOLOv8 classification format?
  2. Have you tested this new version of datumaro with the rest of the project to ensure compatibility?

To ensure that this change doesn't introduce any unexpected issues, please run the following commands:

These commands will help identify any significant changes, particularly those related to YOLOv8 or classification, as well as any updates in documentation that might be relevant to this PR.

✅ Verification successful

Update to datumaro package introduces YOLOv8 Classification support.

The change in commit e1f3c7eb62ebf76ce881b1a7143de5fb3e7d9577 adds support for the YOLOv8 Classification format, aligning with the PR's objective.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any breaking changes or new features in the datumaro package

# Test: Compare the difference between the old and new versions
git clone https://github.com/cvat-ai/datumaro.git
cd datumaro
git diff 393cb666529067060ff57e30cb6e448669274f35 e1f3c7eb62ebf76ce881b1a7143de5fb3e7d9577 -- '*.py'

# Test: Check if there are any changes related to YOLOv8 or classification
git diff 393cb666529067060ff57e30cb6e448669274f35 e1f3c7eb62ebf76ce881b1a7143de5fb3e7d9577 | grep -i "yolo\|classif"

# Test: Look for any updates in the package's documentation or changelog
git diff 393cb666529067060ff57e30cb6e448669274f35 e1f3c7eb62ebf76ce881b1a7143de5fb3e7d9577 -- '*.md' 'docs/*'

Length of output: 46359

cvat/apps/dataset_manager/formats/yolo.py (1)

105-107: Verify testing and documentation for YOLOv8 classification support.

The additions for YOLOv8 classification support are well-integrated and consistent with the existing code structure. However, to ensure the robustness of this new feature:

  1. Confirm that appropriate unit tests have been added or updated to cover the new YOLOv8 classification format.
  2. Ensure that the project's documentation (e.g., user guides, API docs) has been updated to reflect the addition of YOLOv8 classification support.
  3. Verify that any relevant examples or tutorials have been created or updated to demonstrate the use of this new format.

To help verify the testing coverage, you can run the following command:

This will help identify if there are any test files that include references to YOLOv8 classification. If no results are found, it might indicate a need for additional test coverage.

Also applies to: 144-146

✅ Verification successful

Testing and documentation for YOLOv8 Classification support are properly implemented.

The additions for YOLOv8 Classification support include comprehensive unit tests and necessary documentation updates, ensuring the feature is well-supported and documented.

  • Unit Tests:

    • cvat/apps/dataset_manager/tests/test_formats.py
    • cvat/apps/dataset_manager/tests/test_rest_api_formats.py
  • Documentation:

    • README.md
    • site/content/en/docs/manual/advanced/formats/format-yolov8-classification.md
    • site/content/en/docs/manual/advanced/formats/_index.md
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for test files related to YOLO formats
rg -t python --glob '**/test_*.py' -i 'yolo.*classification'

Length of output: 93


Script:

#!/bin/bash
# Search for test files related to YOLOv8 classification
rg --glob 'test_*.py' -i 'yolo.*classification'

Length of output: 893


Script:

#!/bin/bash
# Search for documentation updates related to YOLOv8 classification
rg --glob '*.md' -i 'YOLOv8 Classification'

Length of output: 1028

cvat/requirements/base.txt (1)

59-59: Verify the impact of the datumaro package update.

The update of the datumaro package to a newer commit (e1f3c7eb62ebf76ce881b1a7143de5fb3e7d9577) is noted. This change likely introduces new features, bug fixes, or improvements that could be relevant to supporting the YOLOv8 classification format as mentioned in the PR objectives.

To ensure this update aligns with the PR objectives and doesn't introduce any unintended consequences, please:

  1. Review the changes between the old commit (393cb666529067060ff57e30cb6e448669274f35) and the new one (e1f3c7eb62ebf76ce881b1a7143de5fb3e7d9577) in the datumaro repository.
  2. Verify that these changes support the YOLOv8 classification format or are otherwise beneficial to the project.
  3. Run the test suite to ensure no regressions are introduced by this update.

Would you like me to fetch and summarize the changes between these two commits in the datumaro repository?

✅ Verification successful

Verified: Update to datumaro package adds support for YOLOv8 Classification format.

The changes to the datumaro package successfully introduce support for the YOLOv8 Classification format. This includes necessary converters, extractors, importers, and comprehensive documentation updates. Additionally, new tests have been added to ensure the functionality and reliability of the new features.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Fetch the commit messages and changed files between the two versions
git clone https://github.com/cvat-ai/datumaro.git
cd datumaro
git log --oneline --name-status 393cb666529067060ff57e30cb6e448669274f35..e1f3c7eb62ebf76ce881b1a7143de5fb3e7d9577

Length of output: 2277


Script:

#!/bin/bash
# Navigate to the existing datumaro repository
cd datumaro

# Fetch the latest changes to ensure all commits are available
git fetch origin

# Show the differences between the two specified commits
git diff 393cb666529067060ff57e30cb6e448669274f35 e1f3c7eb62ebf76ce881b1a7143de5fb3e7d9577

Length of output: 38509

cvat/apps/dataset_manager/tests/test_formats.py (3)

293-293: LGTM: YOLOv8 Classification format added to export formats

The addition of 'YOLOv8 Classification 1.0' to the list of export formats is consistent with the PR objective and follows the existing naming convention.


330-330: LGTM: YOLOv8 Classification format added to import formats

The addition of 'YOLOv8 Classification 1.0' to the list of import formats is consistent with the PR objective and maintains consistency with the export formats.


293-293: Summary: YOLOv8 Classification format successfully integrated into test suite

The changes in this file successfully add support for the YOLOv8 Classification format to the test suite. The new format has been added to:

  1. Export formats query test
  2. Import formats query test
  3. Empty images export test

These additions ensure that the new format is properly tested for various scenarios, maintaining consistency with other supported formats.

Also applies to: 330-330, 384-384

cvat/apps/dataset_manager/tests/assets/annotations.json (1)

979-992: LGTM: New YOLOv8 Classification format added correctly

The new "YOLOv8 Classification 1.0" entry has been added successfully to the annotations.json file. The structure is consistent with other entries in the file, including:

  1. Correct version number (0)
  2. A tags array with a single tag object
  3. Empty shapes and tracks arrays

This addition aligns well with the PR objective of supporting the YOLOv8 classification format in CVAT.

cvat/apps/dataset_manager/tests/test_rest_api_formats.py (5)

412-413: LGTM: Addition of YOLOv8 Classification format

The addition of "YOLOv8 Classification 1.0" to the list of formats is appropriate for this test method. It ensures that the new format will be tested for dumping and uploading annotations with shape objects.


521-522: LGTM: YOLOv8 Classification format added to track object test

The addition of "YOLOv8 Classification 1.0" to the list of formats in the test_api_v2_dump_annotations_with_objects_type_is_track method is appropriate. This ensures that the new format will be tested for dumping annotations with track objects.


963-964: LGTM: YOLOv8 Classification format included in annotation rewriting test

The addition of "YOLOv8 Classification 1.0" to the list of formats in the test_api_v2_rewriting_annotations method is appropriate. This ensures that the new format will be tested for the ability to rewrite annotations correctly.


1081-1082: LGTM: YOLOv8 Classification format added to Datumaro dump and upload test

The addition of "YOLOv8 Classification 1.0" to the list of formats in the test_api_v2_tasks_annotations_dump_and_upload_with_datumaro method is appropriate. This ensures that the new format will be tested for compatibility with Datumaro dump and upload operations.


2113-2114: LGTM: YOLOv8 Classification format included in dataset export/import test

The addition of "YOLOv8 Classification 1.0" to the list of formats in the test_api_v2_export_import_dataset method is appropriate. This ensures that the new format will be tested for dataset export and import operations.

@codecov-commenter
Copy link

codecov-commenter commented Sep 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.09%. Comparing base (1285858) to head (3a11bd1).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8475      +/-   ##
===========================================
- Coverage    74.09%   74.09%   -0.01%     
===========================================
  Files          396      396              
  Lines        42768    42774       +6     
  Branches      3897     3897              
===========================================
+ Hits         31691    31694       +3     
- Misses       11077    11080       +3     
Components Coverage Δ
cvat-ui 78.72% <ø> (-0.04%) ⬇️
cvat-server 70.10% <100.00%> (+0.02%) ⬆️

Copy link
Member

@Bobronium Bobronium left a comment

Choose a reason for hiding this comment

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

SonarCloud Code Analysis is failing, could you make it green?

@Eldies
Copy link
Contributor Author

Eldies commented Oct 4, 2024

SonarCloud Code Analysis is failing, could you make it green?

made it green

Copy link
Contributor

github-actions bot commented Oct 4, 2024

✔️ All checks completed successfully
📄 See logs here

Copy link

sonarcloud bot commented Oct 4, 2024

Copy link
Contributor

@nmanovic nmanovic left a comment

Choose a reason for hiding this comment

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

LGTM as well

@Eldies Eldies merged commit 3cde309 into develop Oct 7, 2024
34 checks passed
@Eldies Eldies deleted the dl/yolov8-classification branch October 7, 2024 08:40
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.

4 participants