-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor and restructure anomalib.data (#2302)
* Move datamodules to datamodule sub-package * Move datamodules to datamodule sub-package * Split datamodules and datasets * Restructure dataclasses to data * Fix relative imports * Use absolute imports * Add datasets dir * Add relative imports for torch datasets * Update src/anomalib/data/datamodules/base/__init__.py Co-authored-by: Ashwin Vaidya <[email protected]> --------- Co-authored-by: Ashwin Vaidya <[email protected]>
- Loading branch information
Showing
107 changed files
with
3,326 additions
and
2,867 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""Numpy-based dataclasses for Anomalib. | ||
This module provides numpy-based implementations of the generic dataclasses | ||
used in Anomalib. These classes are designed to work with numpy arrays for | ||
efficient data handling and processing in anomaly detection tasks. | ||
The module includes the following main classes: | ||
- NumpyItem: Represents a single item in Anomalib datasets using numpy arrays. | ||
- NumpyBatch: Represents a batch of items in Anomalib datasets using numpy arrays. | ||
- NumpyImageItem: Represents a single image item with additional image-specific fields. | ||
- NumpyImageBatch: Represents a batch of image items with batch operations. | ||
- NumpyVideoItem: Represents a single video item with video-specific fields. | ||
- NumpyVideoBatch: Represents a batch of video items with video-specific operations. | ||
""" | ||
|
||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from .base import NumpyBatch, NumpyItem | ||
from .image import NumpyImageBatch, NumpyImageItem | ||
from .video import NumpyVideoBatch, NumpyVideoItem | ||
|
||
__all__ = ["NumpyBatch", "NumpyItem", "NumpyImageBatch", "NumpyImageItem", "NumpyVideoBatch", "NumpyVideoItem"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Numpy-based dataclasses for Anomalib. | ||
This module provides numpy-based implementations of the generic dataclasses | ||
used in Anomalib. These classes are designed to work with numpy arrays for | ||
efficient data handling and processing in anomaly detection tasks. | ||
""" | ||
|
||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from dataclasses import dataclass | ||
|
||
import numpy as np | ||
|
||
from anomalib.data.dataclasses.generic import _GenericBatch, _GenericItem | ||
|
||
|
||
@dataclass | ||
class NumpyItem(_GenericItem[np.ndarray, np.ndarray, np.ndarray, str]): | ||
"""Dataclass for a single item in Anomalib datasets using numpy arrays. | ||
This class extends _GenericItem for numpy-based data representation. It includes | ||
both input data (e.g., images, labels) and output data (e.g., predictions, | ||
anomaly maps) as numpy arrays. It is suitable for numpy-based processing | ||
pipelines in Anomalib. | ||
""" | ||
|
||
|
||
@dataclass | ||
class NumpyBatch(_GenericBatch[np.ndarray, np.ndarray, np.ndarray, list[str]]): | ||
"""Dataclass for a batch of items in Anomalib datasets using numpy arrays. | ||
This class extends _GenericBatch for batches of numpy-based data. It represents | ||
multiple data points for batch processing in anomaly detection tasks. It includes | ||
an additional dimension for batch size in all tensor-like fields. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"""Numpy-based depth dataclasses for Anomalib.""" | ||
|
||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.