-
Notifications
You must be signed in to change notification settings - Fork 768
Fix/1370 efficientad validation and pretraining images #1376
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
Open
jpcbertoldo
wants to merge
6
commits into
open-edge-platform:main
Choose a base branch
from
jpcbertoldo:fix/1370
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7a206df
enable efficientnet ad option for pretraining image dir
jpcbertoldo d28b783
add val split mode from_train
jpcbertoldo aa1ab99
Update src/anomalib/models/efficient_ad/lightning_model.py
jpcbertoldo 13d959a
make padding on inference maps automatic when padding=False
jpcbertoldo f52711c
Merge branch 'main' into fix/1370
samet-akcay 312fe6f
Update src/anomalib/models/efficient_ad/lightning_model.py
jpcbertoldo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -59,10 +59,10 @@ class EfficientAd(AnomalyModule): | |
model_size (str): size of student and teacher model | ||
lr (float): learning rate | ||
weight_decay (float): optimizer weight decay | ||
padding (bool): use padding in convoluional layers | ||
pad_maps (bool): relevant if padding is set to False. In this case, pad_maps = True pads the | ||
output anomaly maps so that their size matches the size in the padding = True case. | ||
padding (bool): use padding in convoluional layers of the student/teacher architecture | ||
batch_size (int): batch size for imagenet dataloader | ||
pretraining_images_dir (str): path to folder with images used to pretrain the teacher model | ||
and the code is calling it "imagenette", but it could be any dataset. | ||
""" | ||
|
||
def __init__( | ||
|
@@ -73,8 +73,8 @@ def __init__( | |
lr: float = 0.0001, | ||
weight_decay: float = 0.00001, | ||
padding: bool = False, | ||
pad_maps: bool = True, | ||
batch_size: int = 1, | ||
pretraining_images_dir: str = "./datasets/imagenette", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to make this parameter optional? That way, if it is |
||
) -> None: | ||
super().__init__() | ||
|
||
|
@@ -84,12 +84,12 @@ def __init__( | |
input_size=image_size, | ||
model_size=model_size, | ||
padding=padding, | ||
pad_maps=pad_maps, | ||
) | ||
self.batch_size = batch_size | ||
self.image_size = image_size | ||
self.lr = lr | ||
self.weight_decay = weight_decay | ||
self.pretraining_images_dir = pretraining_images_dir | ||
|
||
self.prepare_pretrained_model() | ||
self.prepare_imagenette_data() | ||
|
@@ -115,8 +115,9 @@ def prepare_imagenette_data(self) -> None: | |
] | ||
) | ||
|
||
imagenet_dir = Path("./datasets/imagenette") | ||
imagenet_dir = Path(self.pretraining_images_dir) | ||
if not imagenet_dir.is_dir(): | ||
raise FileNotFoundError(f"Imagenette dataset not found at {imagenet_dir}") | ||
download_and_extract(imagenet_dir, IMAGENETTE_DOWNLOAD_INFO) | ||
imagenet_dataset = ImageFolder(imagenet_dir, transform=TransformsWrapper(t=self.data_transforms_imagenet)) | ||
self.imagenet_loader = DataLoader(imagenet_dataset, batch_size=self.batch_size, shuffle=True, pin_memory=True) | ||
|
@@ -280,7 +281,6 @@ def __init__(self, hparams: DictConfig | ListConfig) -> None: | |
lr=hparams.model.lr, | ||
weight_decay=hparams.model.weight_decay, | ||
padding=hparams.model.padding, | ||
pad_maps=hparams.model.pad_maps, | ||
image_size=hparams.dataset.image_size, | ||
batch_size=hparams.dataset.train_batch_size, | ||
) | ||
|
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.