Commit db4c285
Add ensembling methods for tiling to Anomalib (#1226)
* Fixed broken links in readme
* Fixed inference command in readme
* Add tiling for ensemble
* Add tests for tiling for ensemble
* Moved ensemble tiler to separate file
* Modify padim config for ensemble
* Add tiling to dataset
* Revert changes to train
* Add tiling to collate fn
* Fix tiling in collate
* Change val. function to protected
* Add tile number logic
* Move collate fn to separate file
* Update tests for tiler
* Add training loop for ensemble
* Add model input size setup
* Move ens config to separate file
* Revert mvtec modifications
* Remove unused imports in mvtec
* Add batch adjustment to untiling
* Add predict step to ensemble
* Add comment and docstring to tile joining function
* Move tile joining to separate function
* Add joining for all tiled data
* Add joining for all box data
* Refactor pred. joining as modular class
* Fix box joining
* Add label and score joining
* Add ensemble visualization
* Add end of predict hook
* Add metric computation
* Fix metric thresholds
* Add removal of individual visualization
* Add demo1 notebook
* Add docstrings and cleanup
* Add memory benchmark
* Add modular class for storing predictions
* Add metric to separate class
* Refactor to support prediction data class
* Rename predictions class
* Add filesystem predictions class
* Add resized predictions class
* Fix joiner for classification task
* Add page peak to memory benchmark
* Add global stats calculation
* Add docstrings to stats calculation
* Refactor joiner for pipeline
* Refactor stats into pipeline
* Refactor metrics as pipeline block
* Refactor visualization as pipeline block
* Refactor postprocessing into a pipeline
* Add normalization and thresholding on joined predictions
* Refactor tiler to accept config file
* Add smoothing of tile joins.
* Refactor ensemble datamodule preparation
* Remove unused changes in dataloader
* Fix metric configuration
* Fix box coordinates in joining
* Add ensemble callbacks preparation function
* Fix box prediction bug in postprocess
* Add ensemble params to config
* Refactor postprocessing.
* Refactor post-processing
* Refactor predictions
* Code cleanup
* Optimize prediction storage
* Make join smoothing configurable
* Cleanup before PR
* Fix stats pipeline
* Fix logging strings
* Fix memory benchmark
* Fix tiler issues
* Fix import issues
* Fix naming in metrics and visualization
* Fix cyclic import
* Make logging lazy
* Refactor tiler tests
* Added collate tiling tests
* Added ensemble helper functions tests
* Refactor for dummy ensemble config
* Refactor for dummy base config
* Add tests for prediction storage
* Add tests for prediction joiner
* Add tests for visualization
* Fix small issues in tests
* Add metrics test
* Add post-processing tests
* Fix tiler to work with different instance
* Move seed setting inside train loop
* Fix pipeline stats bug
* Rename ensemble config fixture
* Add pipeline tests
* Fix config in pipeline tests
* Add training script test
* Fix types and docstrings
* Move and rename to tiled_ensemble
* Fix bug in label joining.
* Remove memory benchmark
* Cleanup files
* Fix metrics setup
* Rename collate function
* Add license to test files
* Rename fixtures
* Add more comments to tiled ensemble training
* Add start of training log message
* Refactor tiler to have explicit arguments
* Refactor pred. storage to have explicit arguments
* Refactor metrics to have explicit arguments
* Refactor visualization to have explicit arguments
* Refactor post-processing to have explicit arguments
* Sort imports
* Add test ensemble script
* Fix join smoothing bug
* Add more documentation to doc-strings
* Remove unused import
* Add brief tiled ensemble documentation
* Update typehints
* Make training args more clear
* Revert addition of no threshold option.
* Refactor normalization and threshold config
* Remove tiled ensemble from docs index
* Add comments to clarify parts of ensemble config
* Improve ensemble config comments
* Add num_tiles attribute to tiler.
* Fix metrics process docstring
* Fix visualization bug and cover with test
* Replace strings with enum
* Improve comments in joiner.
* Fix bug when model doesn't have anomaly maps.
* Improve docstrings (types, clarify).
* Fix visualization tests
* Fix dict membership checks
* Add saving of ensemble config file
* Update test script args
* Cover test script with tests
* Update export warning
* Fix case when no test or val data
* Improve documentation images
* Add images for documentation
* Add codacy suggestion
* Refactor joiner to single class
* Refactor storage names and config
* Update normalization and threshold stage names
* Add transforms independent input size to models
Signed-off-by: blaz-r <[email protected]>
* Make collate function a datamodule attribute
Signed-off-by: blaz-r <[email protected]>
* Refactor tiled ensemble train into pipeline step
Signed-off-by: blaz-r <[email protected]>
* Refactor tiled ensemble prediction into pipeline step
Signed-off-by: blaz-r <[email protected]>
* Refactor tiled ensemble merging into pipeline step
Signed-off-by: blaz-r <[email protected]>
* Refactor tiled ensemble seam smoothing into pipeline step
Signed-off-by: blaz-r <[email protected]>
* Refactor tiled stats calculation into pipeline step
Signed-off-by: blaz-r <[email protected]>
* Fix ckpt loading when predicting on test set.
Signed-off-by: blaz-r <[email protected]>
* Add logging and add tqdm to pipeline steps.
Signed-off-by: blaz-r <[email protected]>
* Refactor normalization pipeline step
Signed-off-by: blaz-r <[email protected]>
* Refactor thresholding into new pipeline job
* Fix transforms issue when predicting with dataloader
* Add visualization as new pipeline step
* Add metrics as new pipeline step
* Format the code and address some lint problems
Signed-off-by: Blaz Rolih <[email protected]>
* Add code to skip test if test split is none
Signed-off-by: Blaz Rolih <[email protected]>
* Add accelerator to metrics and smoothing
Signed-off-by: Blaz Rolih <[email protected]>
* Make threshold acq helper function and add to threshold to metrics
Signed-off-by: Blaz Rolih <[email protected]>
* Make a separate test pipeline
Signed-off-by: Blaz Rolih <[email protected]>
* Restructure tiled ensemble files into directories
Signed-off-by: Blaz Rolih <[email protected]>
* Pipeline code cleanup
Signed-off-by: Blaz Rolih <[email protected]>
* Remove old tiled ensemble files
Signed-off-by: blaz-r <[email protected]>
* Remove old post processing files
Signed-off-by: blaz-r <[email protected]>
* Fix sigma value read in smoothing
Signed-off-by: blaz-r <[email protected]>
* Update stats calc and normalization
Signed-off-by: blaz-r <[email protected]>
* Update args naming convention
Signed-off-by: blaz-r <[email protected]>
* Refactor code for nice config
Signed-off-by: blaz-r <[email protected]>
* Update docs structure for new system
Signed-off-by: blaz-r <[email protected]>
* Cleanup train code
Signed-off-by: blaz-r <[email protected]>
* Fix test script args
Signed-off-by: blaz-r <[email protected]>
* Update box merging
Signed-off-by: blaz-r <[email protected]>
* Refactor helper function tests
Signed-off-by: blaz-r <[email protected]>
* Small changes in helper and engine
Signed-off-by: blaz-r <[email protected]>
* Refactor merging tests
Signed-off-by: blaz-r <[email protected]>
* Refactor tiling tests
Signed-off-by: blaz-r <[email protected]>
* Refactor metrics test
Signed-off-by: blaz-r <[email protected]>
* Add support for different threshold methods
Signed-off-by: blaz-r <[email protected]>
* Format tests
Signed-off-by: blaz-r <[email protected]>
* Change test to predict
Signed-off-by: blaz-r <[email protected]>
* Refactor stats calculation tests
Signed-off-by: blaz-r <[email protected]>
* Refactor prediction data tests
Signed-off-by: blaz-r <[email protected]>
* Update metrics tests
Signed-off-by: blaz-r <[email protected]>
* Move metrics tests to components
Signed-off-by: blaz-r <[email protected]>
* Refactor seam smoothing tests
Signed-off-by: blaz-r <[email protected]>
* Refactor normalization tests
Signed-off-by: blaz-r <[email protected]>
* Move mock stats to conftest
Signed-off-by: blaz-r <[email protected]>
* Fix typehints for generator
Signed-off-by: blaz-r <[email protected]>
* Refactor threshold tests
Signed-off-by: blaz-r <[email protected]>
* Temporarily disable box minmax
Signed-off-by: blaz-r <[email protected]>
* Add tiled ensemble integration test
Signed-off-by: blaz-r <[email protected]>
* Fix normalization tests and add additional merging test
Signed-off-by: blaz-r <[email protected]>
* Add tile collater tests
Signed-off-by: blaz-r <[email protected]>
* Change dataset in tests to dummy
Signed-off-by: blaz-r <[email protected]>
* Format and fix linter errors
Signed-off-by: blaz-r <[email protected]>
* Format and some cleanup
Signed-off-by: blaz-r <[email protected]>
* Rename predict to eval
Signed-off-by: blaz-r <[email protected]>
* Update docs for refactored version of code
Signed-off-by: blaz-r <[email protected]>
* Cleanup the docs
Signed-off-by: blaz-r <[email protected]>
* Update ensemble engine
Signed-off-by: blaz-r <[email protected]>
* Remove boxes from pipelines and tests
Signed-off-by: blaz-r <[email protected]>
* Fix TODO comment issue
Signed-off-by: blaz-r <[email protected]>
* Fix unused model in ens. engine
Signed-off-by: blaz-r <[email protected]>
* Fix path case in test
Signed-off-by: blaz-r <[email protected]>
* Change temporary dir to project_path
Signed-off-by: blaz-r <[email protected]>
* Change mvtec to MVTec in test path
Signed-off-by: Blaz Rolih <[email protected]>
---------
Signed-off-by: blaz-r <[email protected]>
Signed-off-by: Blaz Rolih <[email protected]>
Co-authored-by: Samet Akcay <[email protected]>1 parent 3a403ae commit db4c285
File tree
39 files changed
+3961
-249
lines changed- docs/source
- images/tiled_ensemble
- markdown/guides/how_to/pipelines
- src/anomalib
- data
- base
- utils
- models/components/base
- pipelines/tiled_ensemble
- components
- utils
- tests
- integration/pipelines
- unit/pipelines
- tiled_ensemble
- tools/tiled_ensemble
39 files changed
+3961
-249
lines changedLoading
Lines changed: 254 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
0 commit comments