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

Update anomalib version and requirements #163

Merged
merged 47 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f175a24
renamed download-progress-bar as download
samet-akcay Feb 24, 2022
f841f51
added new download functions to init
samet-akcay Feb 24, 2022
12cd8ee
Added Btech data module
samet-akcay Feb 25, 2022
7bc453f
Added btech tests
samet-akcay Feb 25, 2022
3a32443
Move split functions into a util module
samet-akcay Feb 25, 2022
132ceb1
Modified mvtec
samet-akcay Feb 25, 2022
907281f
added btech to get-datamodule
samet-akcay Feb 25, 2022
16de223
fix typo in btech docstring
samet-akcay Feb 25, 2022
c2353db
update docstring
samet-akcay Feb 25, 2022
287c974
cleanedup dataset download utils
samet-akcay Feb 25, 2022
df8b655
Address mypy
samet-akcay Feb 25, 2022
966ad94
modify config files and update readme.md
samet-akcay Feb 25, 2022
97d98fa
Fix dataset path
samet-akcay Feb 25, 2022
1e78a31
Merge branch 'development' into feature/data/btad
samet-akcay Mar 6, 2022
f6cba9a
Resolved merge conflicts
samet-akcay Mar 15, 2022
9513723
Merge branch 'feature/data/btad' of github.com:openvinotoolkit/anomal…
samet-akcay Mar 15, 2022
b71f4d3
WiP: Created make_dataset function
samet-akcay Mar 15, 2022
28f7d3e
Renamed folder dataset into custom
samet-akcay Mar 22, 2022
83c1384
Added custom dataset tests
samet-akcay Mar 22, 2022
09908b0
updated config.yaml file to show custom dataset is available
samet-akcay Mar 22, 2022
215df46
Added custom dataset to get_datamodule
samet-akcay Mar 22, 2022
ee12a7a
Resolve merge conflicts
samet-akcay Mar 22, 2022
cf22594
Address PR comments
samet-akcay Mar 23, 2022
8b827d4
Merge branch 'development' of github.com:openvinotoolkit/anomalib int…
samet-akcay Mar 23, 2022
2d24d16
Merge branch 'development' of github.com:openvinotoolkit/anomalib int…
samet-akcay Mar 23, 2022
6646c3b
fix dataset path
samet-akcay Mar 23, 2022
b3cf100
Debugging the ci
samet-akcay Mar 24, 2022
00e8020
Fixed folder dataset tests
samet-akcay Mar 24, 2022
8e47bd3
Added code quality checks back to the ci
samet-akcay Mar 24, 2022
314b164
Added code coverage back to pre-merge tests
samet-akcay Mar 24, 2022
492fd29
Do not import openvino at the top level. Cause some import issues whe…
samet-akcay Mar 24, 2022
ff2a0fa
Move nncf to openvino-requirements.txt
samet-akcay Mar 24, 2022
f6101e8
Move opencv to base requirements.txt/
samet-akcay Mar 24, 2022
d10cdb5
Added extension as an option when saving the result images.
samet-akcay Mar 24, 2022
76521cd
Added an extension check
samet-akcay Mar 24, 2022
5651174
python verion 3.7
samet-akcay Mar 24, 2022
9464402
Added opencv contrib python
samet-akcay Mar 24, 2022
98f8145
reverted visualizer callback
samet-akcay Mar 25, 2022
202a084
Convert bmp images to png after downloading btech dataset.
samet-akcay Mar 25, 2022
bf576d7
pylint
samet-akcay Mar 25, 2022
10d2505
ignore arguments differ
samet-akcay Mar 25, 2022
d9917d4
Version to 0.2.5
samet-akcay Mar 25, 2022
f5cad24
Merge branch 'development' of github.com:openvinotoolkit/anomalib int…
samet-akcay Mar 25, 2022
7c068a1
Ignore arguments-differ
samet-akcay Mar 25, 2022
d667532
loosen pandas version
samet-akcay Mar 25, 2022
3309c21
Merge branch 'fix/add-extension-to-save-results' of github.com:openvi…
samet-akcay Mar 25, 2022
ae1cf72
import openvino with absolute import
samet-akcay Mar 25, 2022
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
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ authors:
family-names: Genc
email: utku.genc@intel.com
affiliation: Intel
version: 0.2.4
version: 0.2.5
doi: https://doi.org/10.48550/arXiv.2202.08341
date-released: 2022-02-18
references:
Expand Down
2 changes: 1 addition & 1 deletion anomalib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# See the License for the specific language governing permissions
# and limitations under the License.

__version__ = "0.2.4"
__version__ = "0.2.5"
31 changes: 24 additions & 7 deletions anomalib/data/btech.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from torch.utils.data import DataLoader
from torch.utils.data.dataset import Dataset
from torchvision.datasets.folder import VisionDataset
from tqdm import tqdm

from anomalib.data.inference import InferenceDataset
from anomalib.data.utils import DownloadProgressBar, read_image
Expand Down Expand Up @@ -94,7 +95,9 @@ def make_btech_dataset(
Returns:
DataFrame: an output dataframe containing samples for the requested split (ie., train or test)
"""
samples_list = [(str(path),) + filename.parts[-3:] for filename in path.glob("**/*.bmp")]
samples_list = [
(str(path),) + filename.parts[-3:] for filename in path.glob("**/*") if filename.suffix in (".bmp", ".png")
]
if len(samples_list) == 0:
raise RuntimeError(f"Found 0 images in {path}")

Expand All @@ -107,7 +110,7 @@ def make_btech_dataset(
+ "/ground_truth/"
+ samples.label
+ "/"
+ samples.image_path.str.rstrip("bmp").str.rstrip(".")
+ samples.image_path.str.rstrip("png").str.rstrip(".")
+ ".png"
)

Expand Down Expand Up @@ -337,10 +340,9 @@ def prepare_data(self) -> None:
if (self.root / self.category).is_dir():
logging.info("Found the dataset.")
else:
self.root.mkdir(parents=True, exist_ok=True)
zip_filename = self.root / "btad.zip"
zip_filename = self.root.parent / "btad.zip"

logging.info("Downloading the dataset.")
logging.info("Downloading the BTech dataset.")
with DownloadProgressBar(unit="B", unit_scale=True, miniters=1, desc="BTech") as progress_bar:
urlretrieve(
url="https://avires.dimi.uniud.it/papers/btad/btad.zip",
Expand All @@ -350,10 +352,25 @@ def prepare_data(self) -> None:

logging.info("Extracting the dataset.")
with zipfile.ZipFile(zip_filename, "r") as zip_file:
zip_file.extractall(self.root)
zip_file.extractall(self.root.parent)

logging.info("Renaming the dataset directory")
shutil.move(src=str(self.root / "BTech_Dataset_transformed"), dst=str(self.root / "BTech"))
shutil.move(src=str(self.root.parent / "BTech_Dataset_transformed"), dst=str(self.root))

# NOTE: Each BTech category has different image extension as follows
# | Category | Image | Mask |
# |----------|-------|------|
# | 01 | bmp | png |
# | 02 | png | png |
# | 03 | bmp | bmp |
# To avoid any conflict, the following script converts all the extensions to png.
# This solution works fine, but it's also possible to properly ready the bmp and
# png filenames from categories in `make_btech_dataset` function.
logging.info("Convert the bmp formats to png to have consistent image extensions")
for filename in tqdm(self.root.glob("**/*.bmp"), desc="Converting bmp to png"):
image = cv2.imread(str(filename))
cv2.imwrite(str(filename.with_suffix(".png")), image)
filename.unlink()

logging.info("Cleaning the tar file")
zip_filename.unlink()
Expand Down
2 changes: 1 addition & 1 deletion anomalib/models/dfkde/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def __init__(self, hparams: Union[DictConfig, ListConfig]):
self.embeddings: List[Tensor] = []

@staticmethod
def configure_optimizers():
def configure_optimizers(): # pylint: disable=arguments-differ
"""DFKDE doesn't require optimization, therefore returns no optimizers."""
return None

Expand Down
2 changes: 1 addition & 1 deletion anomalib/models/dfm/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, hparams: Union[DictConfig, ListConfig]):
self.embeddings: List[Tensor] = []

@staticmethod
def configure_optimizers() -> None:
def configure_optimizers() -> None: # pylint: disable=arguments-differ
"""DFM doesn't require optimization, therefore returns no optimizers."""
return None

Expand Down
2 changes: 1 addition & 1 deletion anomalib/models/padim/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def __init__(self, hparams: Union[DictConfig, ListConfig]):
self.embeddings: List[Tensor] = []

@staticmethod
def configure_optimizers():
def configure_optimizers(): # pylint: disable=arguments-differ
"""PADIM doesn't require optimization, therefore returns no optimizers."""
return None

Expand Down
6 changes: 4 additions & 2 deletions anomalib/utils/callbacks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@
from .cdf_normalization import CdfNormalizationCallback
from .min_max_normalization import MinMaxNormalizationCallback
from .model_loader import LoadModelCallback
from .openvino import OpenVINOCallback
from .save_to_csv import SaveToCSVCallback
from .timer import TimerCallback
from .visualizer_callback import VisualizerCallback

__all__ = [
"OpenVINOCallback",
"LoadModelCallback",
"TimerCallback",
"VisualizerCallback",
Expand Down Expand Up @@ -97,6 +95,10 @@ def get_callbacks(config: Union[ListConfig, DictConfig]) -> List[Callback]:
)
)
if "openvino" in config.optimization and config.optimization.openvino.apply:
from .openvino import ( # pylint: disable=import-outside-toplevel
OpenVINOCallback,
)

callbacks.append(
OpenVINOCallback(
input_size=config.model.input_size,
Expand Down
4 changes: 3 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ kornia==0.5.6
lxml==4.6.5
matplotlib==3.4.3
networkx~=2.5
nncf@ git+https://github.com/openvinotoolkit/nncf@37a830a412e60ec2fd2d84d7f00e2524e5f62777#egg=nncf
numpy~=1.19.5
omegaconf==2.1.1
opencv-python>=4.5.3.56
opencv-contrib-python==4.5.5.62
pandas~=1.1.5
pillow==9.0.0
pytorch-lightning==1.5.9
torch==1.8.1
Expand Down
2 changes: 1 addition & 1 deletion requirements/openvino.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defusedxml==0.7.1
requests==2.26.0
networkx~=2.5
nncf@ git+https://github.com/openvinotoolkit/nncf@37a830a412e60ec2fd2d84d7f00e2524e5f62777#egg=nncf
onnx==1.10.1
opencv-python==4.5.3.56
openvino-dev==2021.4.2
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ def get_required_packages(requirement_files: List[str]) -> List[str]:
setup(
name="anomalib",
# TODO: https://github.com/openvinotoolkit/anomalib/issues/36
version="0.2.4",
version="0.2.5",
author="Intel OpenVINO",
author_email="help@openvino.intel.com",
description="anomalib - Anomaly Detection Library",
url="",
license="Copyright (c) Intel - All Rights Reserved. "
'Licensed under the Apache License, Version 2.0 (the "License")'
"See LICENSE file for more details.",
python_requires=">=3.8",
python_requires=">=3.7",
packages=find_packages("."),
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pytorch_lightning.callbacks.early_stopping import EarlyStopping

from anomalib.config import get_configurable_parameters
from anomalib.utils.callbacks import OpenVINOCallback
from anomalib.utils.callbacks.openvino import OpenVINOCallback
from tests.pre_merge.utils.callbacks.openvino_callback.dummy_lightning_model import (
DummyLightningModule,
FakeDataModule,
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ ignore = E203,W503
extension-pkg-whitelist = cv2
ignored-modules = cv2
disable = duplicate-code,
arguments-differ,
fixme,
import-error,
no-self-use,
Expand Down