-
Notifications
You must be signed in to change notification settings - Fork 704
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump up the pytorch lightning to master branch due to vulnurability i…
…ssues (#55) * Bump up the pytorch lightning to master branch due to vulnurability issues. * Updated config files * added Inference Dataset * fix deterministic issue * Modified config files * pl version to 1.5.9 * modified cflow configs * set deterministic off * do not log images when testing. * Bumped up version * Update tox.yml * Add trainer.validate to `run_train_test` in normalization tests * nncf callback * use on_validation_epoch_start instead of on_validation_start in cdf callback * Updated ganomaly configs to match the version Co-authored-by: Dick Ameln <[email protected]>
- Loading branch information
1 parent
d5bc8b0
commit 9d1c0b7
Showing
21 changed files
with
258 additions
and
165 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
"""Inference Dataset.""" | ||
|
||
# Copyright (C) 2020 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions | ||
# and limitations under the License. | ||
|
||
from pathlib import Path | ||
from typing import Any, Optional, Tuple, Union | ||
|
||
import albumentations as A | ||
from torch.utils.data.dataset import Dataset | ||
|
||
from anomalib.data.transforms import PreProcessor | ||
from anomalib.data.utils import get_image_filenames, read_image | ||
|
||
|
||
class InferenceDataset(Dataset): | ||
"""Inference Dataset to perform prediction.""" | ||
|
||
def __init__( | ||
self, | ||
path: Union[str, Path], | ||
pre_process: Optional[PreProcessor] = None, | ||
image_size: Optional[Union[int, Tuple[int, int]]] = None, | ||
transform_config: Optional[Union[str, A.Compose]] = None, | ||
) -> None: | ||
"""Inference Dataset to perform prediction. | ||
Args: | ||
path (Union[str, Path]): Path to an image or image-folder. | ||
pre_process (Optional[PreProcessor], optional): Pre-Processing transforms to | ||
pre-process the input dataset. Defaults to None. | ||
image_size (Optional[Union[int, Tuple[int, int]]], optional): Target image size | ||
to resize the original image. Defaults to None. | ||
transform_config (Optional[Union[str, A.Compose]], optional): Configuration file | ||
parse the albumentation transforms. Defaults to None. | ||
""" | ||
super().__init__() | ||
|
||
self.image_filenames = get_image_filenames(path) | ||
|
||
if pre_process is None: | ||
self.pre_process = PreProcessor(transform_config, image_size) | ||
else: | ||
self.pre_process = pre_process | ||
|
||
def __len__(self) -> int: | ||
"""Get the number of images in the given path.""" | ||
return len(self.image_filenames) | ||
|
||
def __getitem__(self, index: int) -> Any: | ||
"""Get the image based on the `index`.""" | ||
image_filename = self.image_filenames[index] | ||
image = read_image(path=image_filename) | ||
pre_processed = self.pre_process(image=image) | ||
|
||
return pre_processed |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ dataset: | |
format: mvtec | ||
path: ./datasets/MVTec | ||
url: ftp://guest:[email protected]/mvtec_anomaly_detection/mvtec_anomaly_detection.tar.xz | ||
category: leather | ||
category: bottle | ||
task: segmentation | ||
label_format: None | ||
image_size: 256 | ||
|
@@ -47,18 +47,15 @@ trainer: | |
accelerator: null | ||
accumulate_grad_batches: 1 | ||
amp_backend: native | ||
amp_level: O2 | ||
auto_lr_find: false | ||
auto_scale_batch_size: false | ||
auto_select_gpus: false | ||
benchmark: false | ||
check_val_every_n_epoch: 1 | ||
checkpoint_callback: true | ||
default_root_dir: null | ||
deterministic: true | ||
distributed_backend: null | ||
deterministic: false | ||
fast_dev_run: false | ||
flush_logs_every_n_steps: 100 | ||
gpus: 1 | ||
gradient_clip_val: 0 | ||
limit_predict_batches: 1.0 | ||
|
@@ -68,7 +65,7 @@ trainer: | |
log_every_n_steps: 50 | ||
log_gpu_memory: null | ||
max_epochs: 50 | ||
max_steps: null | ||
max_steps: -1 | ||
min_epochs: null | ||
min_steps: null | ||
move_metrics_to_cpu: false | ||
|
@@ -83,14 +80,12 @@ trainer: | |
process_position: 0 | ||
profiler: null | ||
progress_bar_refresh_rate: null | ||
reload_dataloaders_every_epoch: false | ||
replace_sampler_ddp: true | ||
stochastic_weight_avg: false | ||
sync_batchnorm: false | ||
terminate_on_nan: false | ||
tpu_cores: null | ||
track_grad_norm: -1 | ||
truncated_bptt_steps: null | ||
val_check_interval: 1.0 | ||
weights_save_path: null | ||
weights_summary: top |
Oops, something went wrong.