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

Add anomaly openvino task #3057

Conversation

ashwinvaidya17
Copy link
Collaborator

@ashwinvaidya17 ashwinvaidya17 commented Mar 7, 2024

Summary

How to test

task = OTXTaskType.ANOMALY_CLASSIFICATION
model = Padim(input_size=(256, 256), layers=["layer1", "layer2", "layer3"], backbone="resnet18")
transforms = [
    Resize(256, antialias=True),
    ToDtype(torch.float32, scale=True),
    Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)),
]
datamodule = AnomalyDataModule(
            task_type=task,
            data_dir="/home/ashwin/datasets/MVTec/bottle",
            train_transforms=transforms,
            val_transforms=transforms,
            test_transforms=transforms,
        )
engine = Engine(
        datamodule=datamodule,
        task=task,
        model=model,
        val_check_interval=1.0,
        num_sanity_val_steps=0,
    )
engine.train(max_epochs=1)
engine.export(export_format=OTXExportFormatType.OPENVINO)
model = AnomalyOpenVINO(
    model_name="otx-workspace/exported_model.xml",
    async_inference=True,
    use_throughput_mode=False,
)

engine = Engine(
    model=model,
    datamodule=datamodule,
    task=task,
)
engine.test()
engine.predict()

Checklist

  • I have added unit tests to cover my changes.​
  • I have added integration tests to cover my changes.​
  • I have added e2e tests for validation.
  • 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) 2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

harimkang and others added 30 commits November 23, 2023 13:24
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
* Init classification

* Wrap _get_img_data

* Edit detection part

* change the ignore folders

* Reflect reviews

* Fix wrong addition

* Reflect reviews

* Edit the ignore scope

* Decouple OTXModel from MMX frameworks

* Fix pre-commit

* Remove MMXCompatibleModel and make separate function

* Rename the function

* Rename the functions

* Fix precommit
…inotoolkit#2679)

* Edit pyproject.toml for packaging and installation & Add CLI class

* Add test_install test cases & fix description

* Fix install.py docstring style

* Align docsting types and replace tmp_dir_path to tmp_path
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
* Fix coverage error

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
* Make subset_name configurable

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
* Make subset_name configurable

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Add tests

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Fix templates to enable test

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Add memory caching

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Revise to make it prettier

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Fix guide.md

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Fix SIGINT handler

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

---------

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
* Migrate Geti object detection models

* Resolve wrong labeling

* Additional hyper params tuning

* Resolve cli issues

* Remove duplicated codes

* Add packages for classification

* Change message to msg

* Change log method
)

* Fix warning from batch_size auto-inference failure

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Update unit test

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

---------

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
* Add Simple Integration test - CLI otx train

* Fix installation case without cuda/version.json

* Add classification overrides value
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
* added mmsegmentation as dependency

* fixed common_semantic_dataset

* fixed integration tests for segmentation

* fixed hard coded model loading. Changed metric

* add aditional dependency for segmentation

---------

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
Co-authored-by: Kim, Vinnam <vinnam.kim@intel.com>
* Add integration setting cfg into debug folder & Fix integration test to use os.system

* Replace os.system to main function

* Revert debug in TrainConfig

* mmsegmentation registry issue resolve
* Align callbacks

* Add segmentation callbacks
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
* Add 'otx test' & initial commits

* Add setup_guide to otx_test & add GlobalHydra().clear() into train, test

* Replace GlobalHydra clear to with initialize
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
…kit#2708)

* Initial commit for dinov2 implementation

* Add conftest

* Sync with the upstream

* Update test and add freeze, normalize

* Update tests

* Reflect reviews

* Remove num_classes at data preprocessor

* Edit the unit-test

* Remove useless data_preprocessor.num_classes

* mock the torch.hub.load, change the normalize

* Reflect reviews

---------

Co-authored-by: Vinnam Kim <vinnam.kim@intel.com>
…ion) (openvinotoolkit#2711)

* Add unit tests for algo

* Add unit tests for otx/core/data/

* Reflect latest PR

* Reflect reviews

* Set max_refetch
* add new inst-seg to new design

---------

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
Co-authored-by: Kim, Vinnam <vinnam.kim@intel.com>
Co-authored-by: jaegukhyun <jaeguk.hyun@intel.com>
Co-authored-by: Prokofiev Kirill <kirill.prokofiev@intel.com>
Co-authored-by: Harim Kang <harim.kang@intel.com>
* Update data config

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Add resizing to mem caching

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Fix

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Fix

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Fix

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Add example notebook

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Fix rebase conflicts

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Update docstring for custom resolvers

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Fix conflicts

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Add yaml config

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Fix test

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Rerun notebook

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Add example notebook for adding custom model

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Add more descriptions

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

* Remove manually not beautiful stdout from example

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>

---------

Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
…t#2716)

* Change the cls head to make them same with the otx1.5

* Fix mis-input channel for mvn3

* Add light models to guarantee the backward compatibility

* Fix mis-channel of mvn3
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
…oolkit#3007)

* Add Anomaly intg test

* Fix anoamly integration test

* Fix unit-test

* Revert lower torchmetric things

* Fix export tests

* Fix anomalib version to hot-fix commit

* Fix anomalib issues

* Fix tox.ini

* Update otx_efficientnet_v2.yaml
@harimkang
Copy link
Contributor

Please check that the tests related to OV Model are not skipped. :)

ashwinvaidya17 and others added 8 commits March 13, 2024 09:22
* Initial commit for documentation

* Fix typo

* Fix api tutorials

* Fix anomaly task part

* Fix typo train_config to train_subset

* Re-Rocate of api tutorial & write config file explain

* Fix wrong path in api_tutorial

* Change index to grid

* Fix tox build-docs

* Change tabs to tab-set
…notoolkit#3064)

* Initial commit

* Add the logic for auto hlabel information

* Fix precommit
…it#3079)

* Merge draft export XAI version from negvet

* Draft implementation for detection

* Code prettifier for detection

* Remove extra changes

* Remove extra changes

* Forward_explain & export with XAI for InstSeg

* Fix comments

* Minor

* Merge changes with tests

* Update CLI tests

* Update tests

* Comments

* Draft

* Draft

* Fix pre-commit

* Fix pre-commit

* Fix tests

* Fix tests

* Add feature vector for det and InstSeg(openvinotoolkit#1)

* add fv for det

* update det and add isegm

* minor

* minor

* Fix tests

* Minor

* Fix output name order (openvinotoolkit#2)

* Disable tests for speed

* Disable tests for speed

* Restore changes

* Disable tests that cause undetermined failures  for ATSS and Mask RCNN

* Disable rtmdet_inst_tiny XAI tests

* Minor

* Fixes from comments

---------

Co-authored-by: Evgeny Tsykunov <e.tsykunov@gmail.com>
Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
@ashwinvaidya17 ashwinvaidya17 marked this pull request as ready for review March 14, 2024 09:45
@github-actions github-actions bot added TEST Any changes in tests and removed BUILD labels Mar 14, 2024
ashwinvaidya17 and others added 3 commits March 14, 2024 10:47
Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
…odel

Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
@ashwinvaidya17 ashwinvaidya17 changed the base branch from v2 to develop March 14, 2024 12:43
@ashwinvaidya17 ashwinvaidya17 mentioned this pull request Mar 14, 2024
8 tasks
@ashwinvaidya17 ashwinvaidya17 deleted the feature/anomaly_ov_model branch March 18, 2024 10:37
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.