Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information