Skip to content

Commit 8490a01

Browse files
samet-akcayashwinvaidya17
authored andcommitted
Merge main and resolve conflicts (open-edge-platform#2287)
* Reduce rich methods (open-edge-platform#2283) remove rich Signed-off-by: Ashwin Vaidya <[email protected]> * Refactor BaseThreshold to Threshold (open-edge-platform#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 (open-edge-platform#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]>
1 parent 3c39944 commit 8490a01

File tree

6 files changed

+7
-10
lines changed

6 files changed

+7
-10
lines changed

src/anomalib/deploy/inferencers/openvino_inferencer.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,4 @@ def predict(
200200
predictions = self.model(image)
201201
pred_dict = self.post_process(predictions)
202202

203-
return NumpyImageBatch(
204-
image=image,
205-
**pred_dict,
206-
)
203+
return NumpyImageBatch(image=image, **pred_dict)

src/anomalib/models/components/base/anomaly_module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from anomalib import LearningType
2222
from anomalib.dataclasses import Batch, InferenceBatch
23-
from anomalib.metrics.threshold import BaseThreshold
23+
from anomalib.metrics.threshold import Threshold
2424
from anomalib.post_processing import OneClassPostProcessor, PostProcessor
2525

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

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

160-
def _get_instance(self, state_dict: OrderedDict[str, Any], dict_key: str) -> BaseThreshold:
160+
def _get_instance(self, state_dict: OrderedDict[str, Any], dict_key: str) -> Threshold:
161161
"""Get the threshold class from the ``state_dict``."""
162162
class_path = state_dict.pop(dict_key)
163163
module = importlib.import_module(".".join(class_path.split(".")[:-1]))

tests/integration/model/test_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def _get_objects(
178178
"""
179179
# select task type
180180

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

183183
# set extra model args
184184
# TODO(ashwinvaidya17): Fix these Edge cases

tests/unit/data/base/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_get_item_returns_correct_keys_and_shapes(subset: str, datamodule: Anoma
2828
assert batch.image.shape == (4, 3, 256, 256)
2929
assert batch.gt_label.shape == (4,)
3030

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

3434
@staticmethod

tests/unit/data/base/video.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_get_item_returns_correct_keys_and_shapes(datamodule: AnomalibDataModule
4141
# We don't know the shape of the original image, so we only check that it is a list of 4 images.
4242
assert batch.original_image.shape[0] == 4
4343

44-
if subset in ("val", "test"):
44+
if subset in {"val", "test"}:
4545
assert len(batch.gt_label) == 4
4646
assert batch.gt_mask.shape == (4, 256, 256)
4747
assert batch.gt_mask.shape == (4, 256, 256)

tools/inference/gradio_inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def get_inferencer(weight_path: Path) -> Inferencer:
5656
torch_inferencer = module.TorchInferencer
5757
inferencer = torch_inferencer(path=weight_path)
5858

59-
elif extension in (".onnx", ".bin", ".xml"):
59+
elif extension in {".onnx", ".bin", ".xml"}:
6060
openvino_inferencer = module.OpenVINOInferencer
6161
inferencer = openvino_inferencer(path=weight_path)
6262

0 commit comments

Comments
 (0)