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

Feature/remove opencv python #28

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [v0.7.0.dev141]

### Updated

- Remove imgaug from mandatory dependencies to remove the necessity of installing opencv-python which conflicts with the headless version on Windows.

## [v0.7.0.dev140]

### Updated
Expand Down
23 changes: 13 additions & 10 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "anomalib-orobix"
version = "0.7.0.dev140"
version = "0.7.0.dev141"
description = "Orobix anomalib fork"
authors = [
"Intel OpenVINO <[email protected]>",
Expand All @@ -26,10 +26,15 @@ omegaconf = "~2.3"
freia = "~0.2"
wandb = "0.12.17"
gradio = "3.0.2"
imgaug = "0.4.0"
line-profiler = "3.5.1"
jsonargparse = { version = "~4.3.0", extras = ["signatures"] }

imgaug = { version = "0.4.0", optional = true }

[tool.poetry.extras]
# We make imgaug optional as it requires opencv-python instead of the headless version
augmentation = ["imgaug"]

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# BLACK CONFIGURATION #
[tool.black]
Expand Down
2 changes: 1 addition & 1 deletion src/anomalib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
# SPDX-License-Identifier: Apache-2.0

anomalib_version = "0.7.0"
custom_orobix_version = "1.4.0"
custom_orobix_version = "1.4.1"

__version__ = f"{anomalib_version}.dev{custom_orobix_version.replace('.', '')}"
17 changes: 15 additions & 2 deletions src/anomalib/data/utils/augmenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,31 @@
# Copyright (C) 2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0


from __future__ import annotations

import glob
import math
import random
from typing import TYPE_CHECKING

import cv2
import imgaug.augmenters as iaa
import numpy as np
import torch
from torch import Tensor
from torchvision.datasets.folder import IMG_EXTENSIONS

from anomalib.data.utils.generators.perlin import random_2d_perlin

try:
import imgaug.augmenters as iaa

IMGAUG_AVAILABLE = True
except ImportError:
IMGAUG_AVAILABLE = False

if TYPE_CHECKING:
import imgaug.augmenters as iaa


def nextpow2(value):
"""Returns the smallest power of 2 greater than or equal to the input value."""
Expand All @@ -47,6 +56,10 @@ def __init__(
p_anomalous: float = 0.5,
beta: float | tuple[float, float] = (0.2, 1.0),
):
if not IMGAUG_AVAILABLE:
raise ImportError(
"imgaug is not installed, anomalib requires the augmentation extra to be installed to use the Augmenter class"
)
self.p_anomalous = p_anomalous
self.beta = beta

Expand Down
Loading