Skip to content

Commit

Permalink
Merge main and resolve conflicts (openvinotoolkit#2287)
Browse files Browse the repository at this point in the history
* Reduce rich methods (openvinotoolkit#2283)

remove rich

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

* Refactor BaseThreshold to Threshold (openvinotoolkit#2278)

* Refactor BaseThreshold to Threshold

* Add relative import and add tests

Signed-off-by: Samet Akcay <[email protected]>

* Revert threshold.py to base.py

Signed-off-by: Samet Akcay <[email protected]>

* Revert threshold imports

Signed-off-by: Samet Akcay <[email protected]>

* Update tests/unit/metrics/threshold/test_threshold.py

Co-authored-by: Ashwin Vaidya <[email protected]>

---------

Signed-off-by: Samet Akcay <[email protected]>
Co-authored-by: Ashwin Vaidya <[email protected]>

* Enable Ruff Rules: PLW1514 and PLR6201 (openvinotoolkit#2284)

* pre-commit autoupdate

Signed-off-by: Samet Akcay <[email protected]>

* Enable preview feautures, and disable some of the updated features

* Add missing copyrights

Signed-off-by: Samet Akcay <[email protected]>

* Ignore copyrights in notebooks

* "PLW1514", # Add explicit encoding argument

Signed-off-by: Samet Akcay <[email protected]>

* "PLR6201", # Convert to set

Signed-off-by: Samet Akcay <[email protected]>

---------

Signed-off-by: Samet Akcay <[email protected]>

---------

Signed-off-by: Ashwin Vaidya <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Co-authored-by: Ashwin Vaidya <[email protected]>
Co-authored-by: Ashwin Vaidya <[email protected]>
  • Loading branch information
3 people authored and djdameln committed Sep 12, 2024
1 parent 3c39944 commit 8490a01
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 10 deletions.
5 changes: 1 addition & 4 deletions src/anomalib/deploy/inferencers/openvino_inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,4 @@ def predict(
predictions = self.model(image)
pred_dict = self.post_process(predictions)

return NumpyImageBatch(
image=image,
**pred_dict,
)
return NumpyImageBatch(image=image, **pred_dict)
4 changes: 2 additions & 2 deletions src/anomalib/models/components/base/anomaly_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from anomalib import LearningType
from anomalib.dataclasses import Batch, InferenceBatch
from anomalib.metrics.threshold import BaseThreshold
from anomalib.metrics.threshold import Threshold
from anomalib.post_processing import OneClassPostProcessor, PostProcessor

from .export_mixin import ExportMixin
Expand Down Expand Up @@ -157,7 +157,7 @@ def _save_to_state_dict(self, destination: OrderedDict, prefix: str, keep_vars:

return super()._save_to_state_dict(destination, prefix, keep_vars)

def _get_instance(self, state_dict: OrderedDict[str, Any], dict_key: str) -> BaseThreshold:
def _get_instance(self, state_dict: OrderedDict[str, Any], dict_key: str) -> Threshold:
"""Get the threshold class from the ``state_dict``."""
class_path = state_dict.pop(dict_key)
module = importlib.import_module(".".join(class_path.split(".")[:-1]))
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/model/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def _get_objects(
"""
# select task type

task_type = TaskType.CLASSIFICATION if model_name in ("ganomaly", "dfkde") else TaskType.SEGMENTATION
task_type = TaskType.CLASSIFICATION if model_name in {"ganomaly", "dfkde"} else TaskType.SEGMENTATION

# set extra model args
# TODO(ashwinvaidya17): Fix these Edge cases
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/data/base/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_get_item_returns_correct_keys_and_shapes(subset: str, datamodule: Anoma
assert batch.image.shape == (4, 3, 256, 256)
assert batch.gt_label.shape == (4,)

if dataloader.dataset.task in ("detection", "segmentation"):
if dataloader.dataset.task in {"detection", "segmentation"}:
assert batch.gt_mask.shape == (4, 256, 256)

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/data/base/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_get_item_returns_correct_keys_and_shapes(datamodule: AnomalibDataModule
# We don't know the shape of the original image, so we only check that it is a list of 4 images.
assert batch.original_image.shape[0] == 4

if subset in ("val", "test"):
if subset in {"val", "test"}:
assert len(batch.gt_label) == 4
assert batch.gt_mask.shape == (4, 256, 256)
assert batch.gt_mask.shape == (4, 256, 256)
Expand Down
2 changes: 1 addition & 1 deletion tools/inference/gradio_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_inferencer(weight_path: Path) -> Inferencer:
torch_inferencer = module.TorchInferencer
inferencer = torch_inferencer(path=weight_path)

elif extension in (".onnx", ".bin", ".xml"):
elif extension in {".onnx", ".bin", ".xml"}:
openvino_inferencer = module.OpenVINOInferencer
inferencer = openvino_inferencer(path=weight_path)

Expand Down

0 comments on commit 8490a01

Please sign in to comment.