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

Made-imagenette-path-configurable-in-config #1833

Merged
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
11 changes: 7 additions & 4 deletions src/anomalib/models/image/efficient_ad/lightning_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class EfficientAd(AnomalyModule):
"""PL Lightning Module for the EfficientAd algorithm.

Args:
imagenet_dir (Path|str): directory path for the Imagenet dataset
Defaults to ``./datasets/imagenette``.
teacher_out_channels (int): number of convolution output channels
Defaults to ``384``.
model_size (str): size of student and teacher model
Expand All @@ -62,6 +64,7 @@ class EfficientAd(AnomalyModule):

def __init__(
self,
imagenet_dir: Path | str = "./datasets/imagenette",
samet-akcay marked this conversation as resolved.
Show resolved Hide resolved
teacher_out_channels: int = 384,
model_size: EfficientAdModelSize = EfficientAdModelSize.S,
lr: float = 0.0001,
Expand All @@ -72,6 +75,7 @@ def __init__(
) -> None:
super().__init__()

self.imagenet_dir = Path(imagenet_dir)
self.model_size = model_size
self.model: EfficientAdModel = EfficientAdModel(
teacher_out_channels=teacher_out_channels,
Expand Down Expand Up @@ -109,10 +113,9 @@ def prepare_imagenette_data(self, image_size: tuple[int, int] | torch.Size) -> N
],
)

imagenet_dir = Path("./datasets/imagenette")
if not imagenet_dir.is_dir():
download_and_extract(imagenet_dir, IMAGENETTE_DOWNLOAD_INFO)
imagenet_dataset = ImageFolder(imagenet_dir, transform=self.data_transforms_imagenet)
if not self.imagenet_dir.is_dir():
download_and_extract(self.imagenet_dir, IMAGENETTE_DOWNLOAD_INFO)
imagenet_dataset = ImageFolder(self.imagenet_dir, transform=self.data_transforms_imagenet)
self.imagenet_loader = DataLoader(imagenet_dataset, batch_size=self.batch_size, shuffle=True, pin_memory=True)
self.imagenet_iterator = iter(self.imagenet_loader)

Expand Down
Loading