Skip to content

Commit

Permalink
Merge pull request #27 from orobix/hotfix/wrong-extension-handling-an…
Browse files Browse the repository at this point in the history
…omaly

Hotfix/wrong extension handling anomaly
  • Loading branch information
rcmalli authored Jul 14, 2023
2 parents df86188 + 21bc4d9 commit 95f841a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
# Changelog
All notable changes to this project will be documented in this file.

### [1.0.2]

#### Fixed

- Fix anomaly detection training not working when images with non lowercase allowed extension are used (e.g. .BMP)

#### Added

- Increase the number of available extensions for classification and anomaly detection training.

### [1.0.1]

#### Fixed
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "quadra"
version = "1.0.1"
version = "1.0.2"
description = "Deep Learning experiment orchestration library"
authors = [
{name = "Alessandro Polidori", email = "[email protected]"},
Expand Down Expand Up @@ -115,7 +115,7 @@ repository = "https://github.com/orobix/quadra"

# Adapted from https://realpython.com/pypi-publish-python-package/#version-your-package
[tool.bumpver]
current_version = "1.0.1"
current_version = "1.0.2"
version_pattern = "MAJOR.MINOR.PATCH"
commit_message = "build: Bump version {old_version} -> {new_version}"
commit = true
Expand Down
2 changes: 1 addition & 1 deletion quadra/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.0.1"
__version__ = "1.0.2"


def get_version():
Expand Down
2 changes: 1 addition & 1 deletion quadra/datamodules/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from quadra.utils import utils

log = utils.get_logger(__name__)
IMAGE_EXTENSIONS: List[str] = [".jpg", ".jpeg", ".png", ".ppm", ".bmp", ".pgm", ".tif"]
IMAGE_EXTENSIONS: List[str] = [".png", ".jpg", ".jpeg", ".bmp", ".tiff", ".tif", ".pbm", ".pgm", ".ppm", ".pxm", ".pnm"]
TrainDataset = Union[torch.utils.data.Dataset, Sequence[torch.utils.data.Dataset]]
ValDataset = Union[torch.utils.data.Dataset, Sequence[torch.utils.data.Dataset]]
TestDataset = torch.utils.data.Dataset
Expand Down
12 changes: 7 additions & 5 deletions quadra/datasets/anomaly.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from torch import Tensor
from torch.utils.data import Dataset

from quadra.datamodules.base import IMAGE_EXTENSIONS


def create_validation_set_from_test_set(samples: DataFrame, seed: int = 0) -> DataFrame:
"""Craete Validation Set from Test Set.
Expand Down Expand Up @@ -130,11 +132,11 @@ def make_anomaly_dataset(
Returns:
An output dataframe containing samples for the requested split (ie., train or test)
"""
ext = [".png", ".jpg", ".jpeg", ".bmp", ".tiff", ".tif"]
samples_list = []

for e in ext:
samples_list.extend([(str(path),) + filename.parts[-3:] for filename in path.glob(f"**/*{e}")])
samples_list = [
(str(path),) + filename.parts[-3:]
for filename in path.glob("**/*")
if filename.is_file() and os.path.splitext(filename)[-1].lower() in IMAGE_EXTENSIONS
]

if len(samples_list) == 0:
raise RuntimeError(f"Found 0 images in {path}")
Expand Down

0 comments on commit 95f841a

Please sign in to comment.