Skip to content

Commit

Permalink
Feature/remove opencv python (#28)
Browse files Browse the repository at this point in the history
* build: Refactor dependencies to avoid having opencv-python as a requirement

* build: Update version and changelog
  • Loading branch information
lorenzomammana authored Aug 14, 2024
1 parent 1d05c54 commit d8448ec
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 15 deletions.
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

0 comments on commit d8448ec

Please sign in to comment.