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

Refactor OTX Models #4241

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open

Refactor OTX Models #4241

wants to merge 18 commits into from

Conversation

kprokofi
Copy link
Collaborator

@kprokofi kprokofi commented Feb 22, 2025

Summary

  • Combine Explainable models with base models
  • divide classification tasks for better maintenance and cleaner code
  • Remove get_classification_layers and necessity to build models 3 time every time. Move this to incremental checkpoint loading
  • Introduce DataInputParams, incapsulate input_size, mean and scale. Derive mean and std values from Normilize transform and automatically pass it to the model
  • Align all models with same interface, introduce model_name for every model. Note: didn't pay much attention to Anomaly models since we will move them to separate Engine. Same for OV models (we will remove them)

How to test

Checklist

  • I have added unit tests to cover my changes.​
  • I have added integration tests to cover my changes.​
  • I have ran e2e tests and there is no issues.
  • I have added the description of my changes into CHANGELOG in my target branch (e.g., CHANGELOG in develop).​
  • I have updated the documentation in my target branch accordingly (e.g., documentation in develop).
  • I have linked related issues.

License

  • I submit my code changes under the same Apache License that covers the project.
    Feel free to contact the maintainers if that's a concern.
  • I have updated the license header for each file (see an example below).
# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

@github-actions github-actions bot added the TEST Any changes in tests label Feb 24, 2025
Copy link
Collaborator

@ashwinvaidya17 ashwinvaidya17 left a comment

Choose a reason for hiding this comment

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

Thanks for the large refactor! I have one minor comment and one concern related to the anomaly models.

Copy link
Contributor

@sovrasov sovrasov left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!
Is MaskDINO model also deleted?
Can we separate cleaning PRs and refactoring PRs to avoid huge changesets which are hard to review?

@kprokofi
Copy link
Collaborator Author

Thanks for the PR! Is MaskDINO model also deleted? Can we separate cleaning PRs and refactoring PRs to avoid huge changesets which are hard to review?

I understand that there are a lot of changes. However, I decided to delete models, that we rejected and those which are not exposed to Geti. My changes with input size affected all the models and it is better to delete them at all rather than fixing them and tests.

What has been deleted: YOLOV9, MaskDINO, HuggingFace models (we will move HuggingFace functionality to the separate engine) + CLI install (There was no need to delete this file in this PR, but if it is OK, I would not return it back)

@sovrasov
Copy link
Contributor

Thanks for the PR! Is MaskDINO model also deleted? Can we separate cleaning PRs and refactoring PRs to avoid huge changesets which are hard to review?

I understand that there are a lot of changes. However, I decided to delete models, that we rejected and those which are not exposed to Geti. My changes with input size affected all the models and it is better to delete them at all rather than fixing them and tests.

What has been deleted: YOLOV9, MaskDINO, HuggingFace models (we will move HuggingFace functionality to the separate engine) + CLI install (There was no need to delete this file in this PR, but if it is OK, I would not return it back)

Unused models could have been deleted in advance, before the actual refactoring, like Ashwin did with a number of other models, or even tasks

@kprokofi
Copy link
Collaborator Author

kprokofi commented Feb 25, 2025

Thanks for the PR! Is MaskDINO model also deleted? Can we separate cleaning PRs and refactoring PRs to avoid huge changesets which are hard to review?

I understand that there are a lot of changes. However, I decided to delete models, that we rejected and those which are not exposed to Geti. My changes with input size affected all the models and it is better to delete them at all rather than fixing them and tests.
What has been deleted: YOLOV9, MaskDINO, HuggingFace models (we will move HuggingFace functionality to the separate engine) + CLI install (There was no need to delete this file in this PR, but if it is OK, I would not return it back)

Unused models could have been deleted in advance, before the actual refactoring, like Ashwin did with a number of other models, or even tasks

Agree, I will create a separate PR with deleting things and update this one after

@kprokofi
Copy link
Collaborator Author

Cleaning PR: #4247

@kprokofi
Copy link
Collaborator Author

kprokofi commented Mar 4, 2025

PR is updated and ready for review

Copy link

codecov bot commented Mar 6, 2025

Codecov Report

Attention: Patch coverage is 77.43590% with 264 lines in your changes missing coverage. Please review.

Project coverage is 80.43%. Comparing base (31823cd) to head (9e02d07).
Report is 136 commits behind head on develop.

Files with missing lines Patch % Lines
src/otx/core/model/hlabel_classification.py 54.19% 60 Missing ⚠️
src/otx/algo/instance_segmentation/maskrcnn.py 20.37% 43 Missing ⚠️
...c/otx/algo/classification/multiclass_models/vit.py 80.74% 26 Missing ⚠️
src/otx/core/model/multiclass_classification.py 74.24% 17 Missing ⚠️
src/otx/core/model/multilabel_classification.py 75.00% 15 Missing ⚠️
src/otx/core/model/base.py 69.04% 13 Missing ⚠️
.../algo/classification/hlabel_models/mobilenet_v3.py 80.00% 12 Missing ⚠️
src/otx/algo/classification/hlabel_models/vit.py 80.35% 11 Missing ⚠️
...c/otx/algo/classification/multilabel_models/vit.py 80.39% 10 Missing ⚠️
...o/classification/multilabel_models/mobilenet_v3.py 88.88% 5 Missing ⚠️
... and 19 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4241      +/-   ##
===========================================
+ Coverage    77.11%   80.43%   +3.32%     
===========================================
  Files          308      269      -39     
  Lines        30571    24999    -5572     
===========================================
- Hits         23576    20109    -3467     
+ Misses        6995     4890    -2105     
Flag Coverage Δ
py310 79.80% <77.43%> (+2.69%) ⬆️
py311 80.41% <77.43%> (+3.36%) ⬆️

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.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TEST Any changes in tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants