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 XPU support to anomaly task #2677

Merged
merged 149 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 148 commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
c13a79d
Update base.txt
yunchu Jul 7, 2023
228a8ed
Update __init__.py
yunchu Jul 7, 2023
5dfd5fd
Update requirements.txt
yunchu Jul 7, 2023
e67d261
Temporarily skip visual prompting openvino integration test (#2323)
sungchul2 Jul 10, 2023
344f526
Fix import dm.DatasetSubset (#2324)
vinnamkim Jul 10, 2023
cfd7706
Fix semantic segmentation soft prediction dtype (#2322)
negvet Jul 10, 2023
c3dd4aa
Contrain yapf verison lesser than 0.40.0 (#2328)
eunwoosh Jul 10, 2023
19477a3
Fix detection e2e tests (#2327)
jaegukhyun Jul 10, 2023
6b51ba0
Mergeback: Label addtion/deletion 1.2.4 --> 1.4.0 (#2326)
sungmanc Jul 11, 2023
b47ebf3
Bump datumaro up to 1.4.0rc2 (#2332)
yunchu Jul 11, 2023
3a0fff0
Tiling Doc for releases 1.4.0 (#2333)
eugene123tw Jul 11, 2023
91ad751
Bump otx version to 1.4.0rc2 (#2341)
yunchu Jul 12, 2023
85bf95e
OTX deploy for visual prompting task (#2311)
sungchul2 Jul 12, 2023
bb3ab4c
Bump albumentations version in anomaly requirements (#2350)
djdameln Jul 13, 2023
a8c6658
Update action detection (#2346)
jaegukhyun Jul 13, 2023
225ddf1
Fix e2e (#2348)
jaegukhyun Jul 13, 2023
603efca
Update ModelAPI in 1.4 release (#2347)
sovrasov Jul 14, 2023
4a8b079
Add OTX optimize for visual prompting task (#2318)
sungchul2 Jul 14, 2023
06142b6
Update detection docs (#2335)
jaegukhyun Jul 14, 2023
7924b5a
Add visual prompting documentation (#2354)
sungchul2 Jul 14, 2023
ca5f74d
Remove custom modelapi patch in visual prompting (#2359)
sungchul2 Jul 14, 2023
a123ca7
Fix graph metric order and label issues (#2356)
goodsong81 Jul 17, 2023
5ca24e1
Update multi-label document and conversion script (#2358)
sungmanc Jul 17, 2023
c1c0463
Update third party programs (#2365)
yunchu Jul 17, 2023
895bd36
Make anomaly task compatible with older albumentations versions (#2363)
djdameln Jul 17, 2023
3d157ab
Fixing detection saliency map for one class case (#2368)
negvet Jul 17, 2023
edd1a8c
Add e2e test for visual prompting (#2360)
sungchul2 Jul 18, 2023
66e8a67
Fix e2e (#2366)
jaegukhyun Jul 18, 2023
d0e864c
Add Dino head unit tests (#2344)
jaegukhyun Jul 18, 2023
c28c612
Update for release 1.4.0rc2 (#2370)
yunchu Jul 18, 2023
0c4be3c
Fix NNCF training on CPU (#2373)
sovrasov Jul 19, 2023
85bfe9f
Align label order between Geti and OTX (#2369)
eunwoosh Jul 19, 2023
43eb838
Remove CenterCrop from Classification test pipeline and editing missi…
sungmanc Jul 19, 2023
0906811
Fix H-label classification (#2377)
sungmanc Jul 20, 2023
f1234d2
Update for release 1.4 (#2380)
yunchu Jul 21, 2023
7319b20
Switch to PTQ for sseg (#2374)
sovrasov Jul 21, 2023
22aaf2a
Fix invalid import structures in otx.api (#2383)
harimkang Jul 21, 2023
8690bf9
Update for 1.4.0rc4 (#2385)
yunchu Jul 21, 2023
efed624
[release 1.4.0] XAI: Return saliency maps for Mask RCNN IR async infe…
GalyaZalesskaya Jul 25, 2023
4fed654
Update for release 1.4.0 (#2399)
yunchu Jul 25, 2023
183c2cb
Fix broken links in documentation (#2405)
yunchu Jul 31, 2023
2858515
Update exportable code README (#2411)
GalyaZalesskaya Aug 1, 2023
c80bfe6
Updated for release 1.4.1 (#2412)
yunchu Aug 2, 2023
92006b6
Add workaround for the incorrect meta info M-RCNN (used for XAI) (#2437)
negvet Aug 18, 2023
75040e3
Add model category attributes to model template (#2439)
goodsong81 Aug 18, 2023
6b09e65
Update for 1.4.2rc1 (#2441)
yunchu Aug 21, 2023
4f9c2f1
Fix label list order for h-label classification (#2440)
GalyaZalesskaya Aug 21, 2023
230f6f2
Modified fq numbers for lite HRNET (#2445)
yunchu Aug 22, 2023
498bd85
Update PTQ ignored scope for hrnet 18 mod2 (#2449)
sovrasov Aug 24, 2023
948881e
Fix OpenVINO inference for legacy models (#2450)
ashwinvaidya17 Aug 25, 2023
9ebdad6
Update for 1.4.2rc2 (#2455)
yunchu Aug 27, 2023
c553c10
Prevent zero-sized saliency map in tiling if tile size is too big (#2…
sovrasov Aug 28, 2023
250df8e
Update pot fq reference number (#2456)
yunchu Aug 29, 2023
eac3372
Bump datumaro version to 1.5.0rc0 (#2470)
yunchu Sep 1, 2023
2fd7c3e
Set tox version constraint (#2472)
yunchu Sep 1, 2023
00a84df
Bug fix for albumentations (#2467)
ashwinvaidya17 Sep 4, 2023
efcf62f
update for release 1.4.2rc3
yunchu Sep 6, 2023
3ed1e9a
Add a dummy hierarchical config required by MAPI (#2483)
sovrasov Sep 7, 2023
98ad124
bump version to 1.4.2rc4
yunchu Sep 8, 2023
5539c18
Bump datumaro version (#2502)
yunchu Sep 18, 2023
fae472b
Upgrade nncf version for 1.4 release (#2459)
sovrasov Sep 19, 2023
4ddbffc
Update version for release 1.4.2rc5 (#2507)
yunchu Sep 19, 2023
4494955
Update for 1.4.2 (#2514)
yunchu Sep 22, 2023
88deb2d
create branch release/1.5.0
yunchu Sep 25, 2023
b0eac19
Delete mem cache handler after training is done (#2535)
eunwoosh Oct 10, 2023
419a0f2
Fix bug that auto batch size doesn't consider distributed training (#…
eunwoosh Oct 11, 2023
39ec80b
Apply fix progress hook to release 1.5.0 (#2539)
sungmanc Oct 11, 2023
b152d9e
Re introduce adaptive scheduling for training (#2541)
jaegukhyun Oct 11, 2023
b7dd570
Update for release 1.4.3rc1 (#2542)
yunchu Oct 11, 2023
c8c5d22
Mirror Anomaly ModelAPI changes (#2531)
ashwinvaidya17 Oct 12, 2023
aec9f55
Re-introduce adaptive training (#2543)
jaegukhyun Oct 12, 2023
cb94427
Fix auto input size mismatch in eval & export (#2530)
goodsong81 Oct 12, 2023
31f4e7c
Update ref. fq number for anomaly e2e2 (#2547)
yunchu Oct 12, 2023
72ebf7a
Skip e2e det tests by issue2548 (#2550)
yunchu Oct 12, 2023
2190a51
Add skip to chained TC for issue #2548 (#2552)
yunchu Oct 12, 2023
a576962
Update for release 1.4.3 (#2551)
yunchu Oct 12, 2023
f512025
Update MAPI for 1.5 release (#2555)
sovrasov Oct 18, 2023
ac8a7dd
Update ModelAPI configuration (#2564)
sovrasov Oct 19, 2023
a5193b1
Disable QAT for SegNexts (#2565)
sovrasov Oct 19, 2023
8fafd40
Add Anomaly modelAPI changes to releases/1.4.0 (#2563)
ashwinvaidya17 Oct 24, 2023
65ddbfa
Fix the CustomNonLinearClsHead when the batch_size is set to 1 (#2571)
sungmanc Oct 24, 2023
0981035
Update ModelAPI configuration (#2564 from 1.4) (#2568)
sovrasov Oct 24, 2023
0ba7b62
Update for 1.4.4rc1 (#2572)
yunchu Oct 24, 2023
1285168
Hotfix DatasetEntity.get_combined_subset function loop (#2577)
vinnamkim Oct 25, 2023
7cacd94
Revert default input size to `Default` due to YOLOX perf regression (…
goodsong81 Oct 27, 2023
8036994
Fix for the degradation issue of the classification task (#2585)
sungmanc Oct 31, 2023
06775f2
Bump datumaro version to 1.5.1rc3 (#2587)
yunchu Oct 31, 2023
8598b05
Add label ids to anomaly OpenVINO model xml (#2590)
ashwinvaidya17 Oct 31, 2023
23a4644
Fix DeiT-Tiny model regression during class incremental training (#2594)
wonjuleee Nov 1, 2023
a5d12b7
Add label ids to model xml in release 1.5 (#2591)
ashwinvaidya17 Nov 1, 2023
ba1a30d
Fix DeiT-Tiny regression test for release/1.4.0 (#2595)
wonjuleee Nov 1, 2023
c22c683
Fix mmcls bug not wrapping model in DataParallel on CPUs (#2601)
goodsong81 Nov 6, 2023
a4abbed
Fix h-label loss normalization issue w/ exclusive label group of sing…
goodsong81 Nov 6, 2023
3ec4c95
Boost up Image numpy accessing speed through PIL (#2586)
wonjuleee Nov 7, 2023
ce9e858
Add missing import pathlib for cls e2e testing (#2610)
yunchu Nov 7, 2023
794a814
Fix division by zero in class incremental learning for classification…
goodsong81 Nov 7, 2023
d240eba
Unify logger usage (#2612)
eunwoosh Nov 8, 2023
8559def
Fix XAI algorithm for Detection (#2609)
GalyaZalesskaya Nov 8, 2023
0d9dff8
Tighten dependency constraint only adapting latest patches (#2607)
yunchu Nov 9, 2023
68e42d0
Add metadata to optimized model (#2618)
ashwinvaidya17 Nov 9, 2023
d06e079
modify omegaconf version constraint
yunchu Nov 9, 2023
d9cdcc2
[release 1.5.0] Fix XAI algorithm for Detection (#2617)
GalyaZalesskaya Nov 9, 2023
6462a4b
Update dependency constraint (#2622)
yunchu Nov 10, 2023
6d3dd34
Update tpp (#2621)
yunchu Nov 10, 2023
2c9b745
Fix h-label bug of missing parent labels in output (#2626)
goodsong81 Nov 10, 2023
13a3993
Update publish workflow (#2625)
yunchu Nov 10, 2023
07491a0
Merge branch 'releases/1.5.0' into releases/1.4.0 for mergeback 1.4.4…
yunchu Nov 10, 2023
eadbb15
bump datumaro version to ~=1.5.0
yunchu Nov 10, 2023
516d395
fixed mistake while mergeing back 1.4.4
yunchu Nov 10, 2023
d84c3d4
modifiy readme
yunchu Nov 10, 2023
5e5729b
remove openvino model wrapper class
yunchu Nov 13, 2023
0325c14
remove openvino model wrapper tests
yunchu Nov 13, 2023
16dd688
[release 1.5.0] DeiT: enable tests + add ViTFeatureVectorHook (#2630)
GalyaZalesskaya Nov 13, 2023
c461200
Fix docs broken link to datatumaro_h-label
goodsong81 Nov 13, 2023
9f4a34b
Fix wrong label settings for non-anomaly task ModelAPIs
goodsong81 Nov 13, 2023
e459f1f
Merge branch 'releases/1.5.0' into mergeback/1.4.4-to-1.5.0
goodsong81 Nov 13, 2023
51ef6db
Merge pull request #2629 from openvinotoolkit/mergeback/1.4.4-to-1.5.0
yunchu Nov 13, 2023
4ca63e8
Update publish workflow for tag checking (#2632)
yunchu Nov 14, 2023
e3bd52d
Merge branch 'releases/1.5.0' into mergeback/1.5.0
yunchu Nov 14, 2023
061aecf
Update e2e tests for XAI Detection (#2634)
GalyaZalesskaya Nov 15, 2023
104404b
Merge pull request #2633 from openvinotoolkit/mergeback/1.5.0
yunchu Nov 15, 2023
9f591b6
Disable QAT for newly added models (#2636)
jaegukhyun Nov 15, 2023
a2545f9
Update release note and readme (#2637)
yunchu Nov 15, 2023
5f1d0ba
Merge branch 'releases/1.4.0' into mergeback/1.4.4rc2
yunchu Nov 15, 2023
0e09a19
update release note and, changelog, and readme
yunchu Nov 15, 2023
8107372
Merge branch 'releases/1.5.0' into mergeback/1.4.4rc2
yunchu Nov 15, 2023
9909d17
Merge pull request #2639 from openvinotoolkit/mergeback/1.4.4rc2
yunchu Nov 16, 2023
26d0fb4
Merge branch 'releases/1.5.0' into mergeback/1.5.0
yunchu Nov 16, 2023
dd84a24
update version string to 1.6.0dev
yunchu Nov 16, 2023
202c193
fix datumaro version to 1.6.0rc0
yunchu Nov 16, 2023
2f67686
Mergeback 1.5.0 to develop (#2642)
yunchu Nov 17, 2023
ddd73f2
Revert "Mergeback 1.5.0 to develop" (#2645)
yunchu Nov 17, 2023
5f62d47
Merge pull request #2646 from openvinotoolkit/mergeback/1.5.0
yunchu Nov 17, 2023
9cf5624
Add a tool to help conduct experiments (#2651)
eunwoosh Nov 20, 2023
72cf37c
Revert inference batch size to 1 for instance segmentation (#2648)
goodsong81 Nov 20, 2023
6b8729a
Remove unnecessary log while building a model (#2658)
eunwoosh Nov 21, 2023
0fbfbb1
Fix a minor bug of experiment.py (#2662)
eunwoosh Nov 22, 2023
090ae97
Not check avg_time_per_image during test (#2665)
eunwoosh Nov 22, 2023
07c1976
Merge remote-tracking branch 'origin/develop' into develop-idev
sovrasov Nov 22, 2023
aeca9f1
Update device selection logic in classificaiton
sovrasov Nov 22, 2023
5b24f50
Add xpu accelerator
sovrasov Nov 22, 2023
7b3b133
Tmp patch for anomaly trainer
sovrasov Nov 22, 2023
dbe0708
Use XPU callback for anomaly training
sovrasov Nov 24, 2023
5961af9
Update xpu accelerator
sovrasov Nov 27, 2023
2a85dfc
Fix for anomaly xpu callback
sovrasov Nov 28, 2023
c1e741c
Fix validation batch logic
sovrasov Nov 28, 2023
0118b48
Merge remote-tracking branch 'origin/develop-idev' into vs/anomaly_xpu
sovrasov Nov 29, 2023
98ffd5d
Cleanup, add docstrings
sovrasov Nov 29, 2023
3f3c4d3
Refine xpu callback
sovrasov Nov 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@

from .inference import AnomalyInferenceCallback
from .progress import ProgressCallback
from .xpu import XPUCallback

__all__ = ["AnomalyInferenceCallback", "ProgressCallback"]
__all__ = ["AnomalyInferenceCallback", "ProgressCallback", "XPUCallback"]
39 changes: 39 additions & 0 deletions src/otx/algorithms/anomaly/adapters/anomalib/callbacks/xpu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Anomaly XPU device callback."""
# Copyright (C) 2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#

import torch
from pytorch_lightning import Callback

from otx.algorithms.common.utils.utils import is_xpu_available


class XPUCallback(Callback):
"""XPU device callback.

Applies IPEX optimization before training, moves data to XPU.
"""

def __init__(self, device_idx=0):
self.device = torch.device(f"xpu:{device_idx}")

def on_fit_start(self, trainer, pl_module):
"""Applies IPEX optimization before training."""
if is_xpu_available():
sovrasov marked this conversation as resolved.
Show resolved Hide resolved
pl_module.to(self.device)
model, optimizer = torch.xpu.optimize(trainer.model, optimizer=trainer.optimizers[0], dtype=torch.float32)
sovrasov marked this conversation as resolved.
Show resolved Hide resolved
trainer.optimizers = [optimizer]
trainer.model = model

def on_train_batch_start(self, trainer, pl_module, batch, batch_idx):
"""Moves train batch tensors to XPU."""
for k in batch:
if not isinstance(batch[k], list):
sungchul2 marked this conversation as resolved.
Show resolved Hide resolved
batch[k] = batch[k].to(self.device)

def on_validation_batch_start(self, trainer, pl_module, batch, batch_idx, dataloader_idx):
"""Moves validation batch tensors to XPU."""
for k in batch:
if not isinstance(batch[k], list):
batch[k] = batch[k].to(self.device)
5 changes: 5 additions & 0 deletions src/otx/algorithms/anomaly/tasks/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
from pytorch_lightning import Trainer, seed_everything

from otx.algorithms.anomaly.adapters.anomalib.callbacks import ProgressCallback
from otx.algorithms.anomaly.adapters.anomalib.callbacks.xpu import XPUCallback
from otx.algorithms.anomaly.adapters.anomalib.data import OTXAnomalyDataModule
from otx.algorithms.common.utils.utils import is_xpu_available
from otx.api.entities.datasets import DatasetEntity
from otx.api.entities.model import ModelEntity
from otx.api.entities.train_parameters import TrainParameters
Expand Down Expand Up @@ -88,6 +90,9 @@ def train(
),
]

if is_xpu_available():
callbacks.append(XPUCallback())

self.trainer = Trainer(**config.trainer, logger=False, callbacks=callbacks)
self.trainer.fit(model=self.model, datamodule=datamodule)

Expand Down