Skip to content

Conversation

@kprokofi
Copy link
Contributor

@kprokofi kprokofi commented Jun 4, 2025

Summary

  • Move current OTX modules under Native backend
  • Refactor "core" and "algo" folder
  • Refine all imports
  • Move unit tests

New structure:

New structure:

# New structure:

otx/
├── backend/  # Contains all backend implementations
│   ├── native/
│   │   ├── callbacks/              # Custom OTX callbacks
│   │   ├── cli/                    # CLI functionality and utilities
│   │   ├── exporter/               # OTX export logic; might be moved to a shared base folder to orchestrate exports across all backends
│   │   ├── lightning/              # Custom Lightning-specific components (e.g., accelerators, plugins, strategies)
│   │   ├── models/                 # Task-specific and shared model implementations
│   │   │   ├── anomaly/            # Models for anomaly detection
│   │   │   ├── classification/     # Models for image classification
│   │   │   ├── common/             # Shared components used across tasks
│   │   │   ├── detection/          # Models for object detection (base model resides in task folder now)
│   │   │   ├── instance_segmentation/  # Models for instance segmentation
│   │   │   ├── keypoint_detection/     # Models for keypoint detection
│   │   │   ├── modules/            # Internal modules for model building
│   │   │   ├── samplers/           # Samplers used in training pipelines
│   │   │   ├── segmentation/       # Models for semantic segmentation
│   │   │   ├── utils/              # Utilities specific to models
│   │   │   ├── __init__.py
│   │   │   └── base.py             # Base OTXModel class used by all tasks
│   │   ├── optimizers/             # Custom optimizers for training
│   │   ├── schedulers/             # Custom learning rate schedulers
│   │   ├── tools/                  # Additional utilities such as batch size search, explainability tools, and AutoConfigurator
│   │   ├── utils/                  # General-purpose utilities for the native backend
│   │   ├── __init__.py
│   │   └── engine.py               # Core training and inference logic for the native backend
│   └── openvino/
│       ├── models/                 # OpenVINO-compatible model wrappers
│       ├── __init__.py
│       └── engine.py               # Inference engine for OpenVINO backend
├── cli/                            # Entry point and shared CLI logic
├── config/                         # DTO configurations
├── data/                           # All data-related components
│   ├── dataset/                    # Dataset implementations and wrappers
│   ├── entity/                     # Data entity
│   │   ├── torch/                  # Torch-based OTX data entities (OTXDataItem)
│   │   ├── __init__.py
│   │   ├── base.py                 # Base class for data entities
│   │   ├── tile.py                 # Tiling-related data entity
│   │   └── utils.py                # Utility functions for entities
│   ├── transform_libs/            # Libraries for data transformations
│   ├── utils/                      # Shared utilities for data module
│   ├── __init__.py
│   ├── factory.py                  # Data factory for loading/preparing datasets
│   ├── mem_cache.py                # Caching mechanism for dataset loading
│   └── module.py                   # OTXDataModule implementation
├── engine/                         # Training and inference engine logic (abstract)
├── metrics/                        # Evaluation metrics and metric calculators 
├── recipe/                         # Training recipes and hyperparameter configurations
├── tools/                          # Integration tools for Geti + Geti templates (will be removed)
├── types/                          # Type definitions
└── utils/                          # Global utility functions used across the project
# API example (models and dataset import):

from otx.backend.native.models import ATSS, EfficientNetMulticlassCls, SegNext
from otx.backend.openvino.models import OVDetectionModel

from otx.data.datasets import OTXInstanceSegDataset, OTXAnomalyDataset, OTXUltaliticsDataset
from otx.data.entity import OTXDataItem

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 DEPENDENCY Any changes in any dependencies (new dep or its version) should be produced via Change Request on PM TEST Any changes in tests BUILD DOC Improvements or additions to documentation labels Jun 4, 2025
Copy link
Contributor

@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 efforts! I have some minor comments.

I couldn't comment on the file but I have concerns about src/otx/types/label.py. The types here are specific to the native backend. Maybe we can have backend.native.types?

@kprokofi
Copy link
Contributor Author

kprokofi commented Jun 6, 2025

Thanks for the efforts! I have some minor comments.

I couldn't comment on the file but I have concerns about src/otx/types/label.py. The types here are specific to the native backend. Maybe we can have backend.native.types?

We use LableInfo for our datumaro datasets. Our datasets will be shared across all backends. So, I would rather keep labels.py in the base "types" folder

@kprokofi kprokofi marked this pull request as ready for review June 6, 2025 11:27
Copy link
Contributor

@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.

Some minor picky comments but feel free to ignore

@rajeshgangireddy rajeshgangireddy requested a review from Copilot June 10, 2025 09:22

This comment was marked as outdated.

@rajeshgangireddy
Copy link
Contributor

rajeshgangireddy commented Jun 10, 2025

│ │ ├── exporter/ # OTX export logic; might be moved to a shared base folder to orchestrate exports across all backends

I agree. I think we should move code from exporter outside specific backends to something like model_converter.

I have a different question.

│ │ │ ├── samplers/ # Samplers used in training pipelines

Why is samplers in models directory ? Wouldn't it be common for all backends which can perform training ?

@kprokofi
Copy link
Contributor Author

│ │ ├── exporter/ # OTX export logic; might be moved to a shared base folder to orchestrate exports across all backends

I agree. I think we should move code from exporter outside specific backends to something like model_converter.

I have a different question.

│ │ │ ├── samplers/ # Samplers used in training pipelines

Why is samplers in models directory ? Wouldn't it be common for all backends which can perform training ?

  1. We will move it later depending on the Exporter design. For now we use it only for Native.
  2. Let's place it under the data folder. "otx.data.samplers". What do you think?

@sovrasov
Copy link
Member

samplers/ # Samplers used in training

Agree that samplers can be moved out from models

@kprokofi
Copy link
Contributor Author

Samplers are moved under data folder

@kprokofi kprokofi requested a review from Copilot June 10, 2025 21:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR reorganizes the OTX repository by moving existing OTX modules under a new backend/native folder, refactoring core and algo directories, and updating all import paths accordingly. It also removes outdated developer guides and example notebooks.

  • Moves OTX modules into otx/backend/native and adjusts folder hierarchy
  • Removes legacy for_developers guides and Jupyter notebook
  • Updates import statements across documentation and code to reflect new module paths

Reviewed Changes

Copilot reviewed 732 out of 732 changed files in this pull request and generated no comments.

Show a summary per file
File Description
for_developers/dir_structure.md Deleted outdated directory-structure guide
for_developers/contribution_guide.md Deleted outdated contribution guide
for_developers/add_custom_model.ipynb Deleted example notebook
docs/source/.../how_to_train/*.rst Updated import paths for SubsetConfig and OTXDataModule
docs/source/.../advanced/*.rst Updated imports to otx.backend.native for models, callbacks, schedulers
docs/source/.../get_started/*.rst Updated imports from otx.core.* to new top-level and backend paths
docs/source/.../explanation/additional_features/*.rst Updated imports for config, data, samplers, callbacks
docker/download_pretrained_weights.py Updated instantiator import path
Comments suppressed due to low confidence (2)

for_developers/dir_structure.md:1

  • The developer directory-structure guide was removed in this PR; please add or point to an updated guide reflecting the new otx/backend/native hierarchy so developers can reference the current layout.
entire file removed

for_developers/contribution_guide.md:1

  • The contribution guide has been deleted; ensure there is a replacement that explains the proposal and review process under the new structure to onboard contributors smoothly.
entire file removed

@kprokofi kprokofi merged commit bdaef0c into open-edge-platform:feature-v3 Jun 11, 2025
52 of 58 checks passed
sovrasov added a commit that referenced this pull request Jun 25, 2025
* Update feature branch (#4333)

* Update Documentation (#4294)

* update docs

* walk through docs

* minor

* modify docs

* fix readme

* update readme. Delete outdated sections

* 🧹 Minor cleanup (#4299)

Refactor import statements to use 'otx.algo.utils.utils' for InstanceData across multiple files

* Promote/Demote Inst Seg Algo (#4301)

Update model categories in Mask R-CNN templates for balance and accuracy

* Reduce Integration Test Scope (#4303)

* Reduce Integration Test Scope to 2-3 recipes per task
* Add PR comment trigger workflow

* Improve PR comment event trigger (#4307)

* Add GitHub Actions comments for workflow run status in PR

* Update permissions in PR comment trigger workflow (#4309)

* Update PR comment trigger (#4312)

Update PR comment trigger workflow to enhance permissions and improve PR description updates

* Add workflow step to update PR description with run link and status (#4314)

* Enhance PR comment trigger to include last commit message and workflow result (#4316)

Enhance PR comment trigger to include last commit message and workflow run summary

* Refactor PR comment trigger (#4318)

Refactor PR comment trigger to include workflow status emoji and streamline run summary

* Support linear classifier fine-tuning for classification models (#4298)

* Backbone frozen in engine.py and head_only.yaml in multi_class_cls

* update

* Add : implemented linear fine-tuning for model layers

* Updated frozen backbone settings/

* fixes from comments #4286

* Removed the coed comments #4298

* fixes from review #4298

* trailing space and removed head_only.yaml #4298

* Resolve the Dependency Inversion Problem#4298

* removed white space #4298

Update engine.py

* removed white space #4298

* pre-commit

* Added Unit test for frrze_backbone

* update precommit

* modified test_freeze_backbone in test_deit_tiny.py

* modified test_freeze_backbone in test_deit_tiny.py

* modified test_freeze_backbone in test_deit_tiny.py

* run pre-commit

---------

Co-authored-by: Vladislav Sovrasov <[email protected]>

* 🧹 Refactor detection entity (#4322)

* Remove detection entity

---------

Signed-off-by: Ashwin Vaidya <[email protected]>

* Update integration test commands to include run-category-only flag options (#4325)

* Bump rich from 13.9.4 to 14.0.0 (#4324)

Bumps [rich](https://github.com/Textualize/rich) from 13.9.4 to 14.0.0.
- [Release notes](https://github.com/Textualize/rich/releases)
- [Changelog](https://github.com/Textualize/rich/blob/master/CHANGELOG.md)
- [Commits](Textualize/rich@v13.9.4...v14.0.0)

---
updated-dependencies:
- dependency-name: rich
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

---------

Signed-off-by: Ashwin Vaidya <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Prokofiev Kirill <[email protected]>
Co-authored-by: Eugene Liu <[email protected]>
Co-authored-by: limgyuil <[email protected]>
Co-authored-by: Vladislav Sovrasov <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Move engine to native

Signed-off-by: Ashwin Vaidya <[email protected]>

* Fix tests

Signed-off-by: Ashwin Vaidya <[email protected]>

* Add readme

Signed-off-by: Ashwin Vaidya <[email protected]>

* ⛙ Merge develop to feature (#4338)

* Update Documentation (#4294)

* update docs

* walk through docs

* minor

* modify docs

* fix readme

* update readme. Delete outdated sections

* 🧹 Minor cleanup (#4299)

Refactor import statements to use 'otx.algo.utils.utils' for InstanceData across multiple files

* Promote/Demote Inst Seg Algo (#4301)

Update model categories in Mask R-CNN templates for balance and accuracy

* Reduce Integration Test Scope (#4303)

* Reduce Integration Test Scope to 2-3 recipes per task
* Add PR comment trigger workflow

* Improve PR comment event trigger (#4307)

* Add GitHub Actions comments for workflow run status in PR

* Update permissions in PR comment trigger workflow (#4309)

* Update PR comment trigger (#4312)

Update PR comment trigger workflow to enhance permissions and improve PR description updates

* Add workflow step to update PR description with run link and status (#4314)

* Enhance PR comment trigger to include last commit message and workflow result (#4316)

Enhance PR comment trigger to include last commit message and workflow run summary

* Refactor PR comment trigger (#4318)

Refactor PR comment trigger to include workflow status emoji and streamline run summary

* Support linear classifier fine-tuning for classification models (#4298)

* Backbone frozen in engine.py and head_only.yaml in multi_class_cls

* update

* Add : implemented linear fine-tuning for model layers

* Updated frozen backbone settings/

* fixes from comments #4286

* Removed the coed comments #4298

* fixes from review #4298

* trailing space and removed head_only.yaml #4298

* Resolve the Dependency Inversion Problem#4298

* removed white space #4298

Update engine.py

* removed white space #4298

* pre-commit

* Added Unit test for frrze_backbone

* update precommit

* modified test_freeze_backbone in test_deit_tiny.py

* modified test_freeze_backbone in test_deit_tiny.py

* modified test_freeze_backbone in test_deit_tiny.py

* run pre-commit

---------

Co-authored-by: Vladislav Sovrasov <[email protected]>

* 🧹 Refactor detection entity (#4322)

* Remove detection entity

---------

Signed-off-by: Ashwin Vaidya <[email protected]>

* Update integration test commands to include run-category-only flag options (#4325)

* Bump rich from 13.9.4 to 14.0.0 (#4324)

Bumps [rich](https://github.com/Textualize/rich) from 13.9.4 to 14.0.0.
- [Release notes](https://github.com/Textualize/rich/releases)
- [Changelog](https://github.com/Textualize/rich/blob/master/CHANGELOG.md)
- [Commits](Textualize/rich@v13.9.4...v14.0.0)

---
updated-dependencies:
- dependency-name: rich
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Fix integration test commands run-category-only flag (#4329)

* updated repo with mobilenet_v4 (#4321)

* updated repo with mobilenet_v4

* Introduce MobileNetV4 for Improved Performance

* Introduced MobileNetV4 recipe for Improved Performance

---------

Co-authored-by: Vladislav Sovrasov <[email protected]>

* Update documentation and references to Open-Edge Platform (#4331)

* Update documentation and references to Open-Edge Platform- Updated dataset format links in auto_configuration.rst, models_optimization.rst, and various algorithm documentation to point to the Open-Edge Platform repository.
- Changed references from openvinotoolkit to open-edge-platform in multiple files including anomaly detection, classification, object detection, segmentation, and product design documentation.
- Modified installation instructions and CLI command references to reflect the new repository URL.
- Adjusted the help formatter to display the updated GitHub repository link.
- Ensured all links to Datumaro and related resources are consistent with the new repository structure.

* 🧹 Refactor Instance Segmentation Entity (#4327)

Signed-off-by: Ashwin Vaidya <[email protected]>

* 🧹 Refactor Anomaly Entities (#4328)

* Remove anomaly entities

Signed-off-by: Ashwin Vaidya <[email protected]>

---------

Signed-off-by: Ashwin Vaidya <[email protected]>

* Add a contribution guide (#4335)

* Add a contribution guide

* Fix a typo

* Apply grammar suggestions

Co-authored-by: Rajesh Gangireddy <[email protected]>

---------

Co-authored-by: Rajesh Gangireddy <[email protected]>

* Bug Fix : Convert labels for multi-label Classification into LongTensor before one_hot encoding (#4336)

* Update classification.py

* make ruff happy

* make it simpler

* Update src/otx/core/data/dataset/classification.py

Co-authored-by: Daan Krol <[email protected]>

---------

Co-authored-by: Daan Krol <[email protected]>

* Bump OV and NNCF to 2025.1 (#4334)

* Bump OV to 2025.1

* Bump NNCF

* Update changelog

* Update imports

---------

Signed-off-by: Ashwin Vaidya <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Prokofiev Kirill <[email protected]>
Co-authored-by: Eugene Liu <[email protected]>
Co-authored-by: limgyuil <[email protected]>
Co-authored-by: Vladislav Sovrasov <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Gaurav Singh <[email protected]>
Co-authored-by: Rajesh Gangireddy <[email protected]>
Co-authored-by: Daan Krol <[email protected]>

* commit changes

Signed-off-by: Ashwin Vaidya <[email protected]>

* Fix tests

Signed-off-by: Ashwin Vaidya <[email protected]>

* Restructure folder

Signed-off-by: Ashwin Vaidya <[email protected]>

* update imports

Signed-off-by: Ashwin Vaidya <[email protected]>

* Delete mobilenetv4

Signed-off-by: Ashwin Vaidya <[email protected]>

* [feature-v3] Add OV Engine (#4374)

* add OV engine as a backend

* update engine

* move backend

* test works

* add predict, delete OVModels

* fix optimize

* add unit test for OVEngine

* fix ruff

* fix mypy issues

* update changes from feature branch

* some fixes

* added API tests with ov_engine

* reply to comments, update docstrings

* inherit OVEngine from Engine

* fix API tests

* fix tests

* fix rest_engine

* try to delete test to check:

* [feature-v3] Move rest of OTX under native backend. Change structure of the folders. (#4408)

* move all folders under native

* add missing files

* delete for developers

* add annotations to types

* update __init__

* align AnomalyDataset with OTXDataset

* move cspnext to detection to avoid circular error

* fix linter

* move all unit test

* fix linter

* return __init__ to openvino backend tests

* reply comments

* fix unit tests. Fix class patch

* change copyright

* fix recipe path

* fix inst seg. Move samplers

* minor fix from copilot

* [feature-v3] Remove T_* data entities (#4412)

* remove T_* entities

* fix linter

* fix API test

* resolve conflicts

* fix typing

* remove all ignores

* minor fix

* fix duplication

* [feature-v3] Integrate "create_engine" to tests and polish engine interface (#4414)

* align engines

* engine.data instead of engine.datamodule

* add missing files

* fix all issues with get_engine()

* add missing files

* fix linter

* delete task from Engine

* simplify the logic of auto-configurator

* decrease bum of epochs

* remove task from all configs

* fix converter test

* fix linter

* small fix to unit test

* fix integration tests and delete unnecessary auto configuration test

* add yaml to configs

* small fix for linter

* fix unit tests

* fix integration

* fix bandit

* fix anomaly tests|

---------

Signed-off-by: Ashwin Vaidya <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Prokofiev Kirill <[email protected]>
Co-authored-by: Eugene Liu <[email protected]>
Co-authored-by: limgyuil <[email protected]>
Co-authored-by: Vladislav Sovrasov <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Gaurav Singh <[email protected]>
Co-authored-by: Rajesh Gangireddy <[email protected]>
Co-authored-by: Daan Krol <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BUILD DEPENDENCY Any changes in any dependencies (new dep or its version) should be produced via Change Request on PM DOC Improvements or additions to documentation TEST Any changes in tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants