This is an official implementation of weighted kNN density estimation for out-of-distribution (OOD) detection for SEM images. The associated journal paper "Out-of-distribution detection with non-parametric density estimation for models predicting processing history of uranium ore concentrates" can be found via this link.
- Clone the repository
git clone https://devops.pnnl.gov/proteus/ood_detection.git
cd ood_detection
- Install required libraries
pip install -e .
Follow the specification of parameters below to train, performance inference, or evaluate OOD detection. Specific examples can be found in the scripts folder.
python main.py *args*
gpu_id- Specify the GPU# to run the model onexp_name- Name of current experimentconfig_file- Location of config file that stores necessary parametersstage- Execution stage [train|test|run_ood]seed- Random seedsaved_mode_file- Location of model weightscrop_type- type of crop used on an input
./scripts/ood_script.sh
Authors: Cuong Ly, Cody Nizinski, Alex Hagen If you find this repository useful, please consider citing our work:
@article{LY2025114148,
title = {Out-of-distribution detection with non-parametric density estimation for models predicting processing history of uranium ore concentrates},
journal = {Computational Materials Science},
volume = {259},
pages = {114148},
year = {2025},
issn = {0927-0256},
doi = {https://doi.org/10.1016/j.commatsci.2025.114148},
url = {https://www.sciencedirect.com/science/article/pii/S0927025625004914},
author = {Cuong Ly and Cody Nizinski and Luther W. McDonald and Aaron Chalifoux and Alex Hagen},
}
This implementation is benefited greatly from the publicly available codes from Barteli and MISO.
Please contact nhatcuong.ly@pnnl.gov for questions and supports.
This material was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor the United States Department of Energy, nor Battelle, nor any of their employees, nor any jurisdiction or organization that has cooperated in the development of these materials, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness or any information, apparatus, product, software, or process disclosed, or represents that its use would not infringe privately owned rights.
Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or any agency thereof, or Battelle Memorial Institute. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or any agency thereof.
PACIFIC NORTHWEST NATIONAL LABORATORY
operated by
BATTELLE
for the
UNITED STATES DEPARTMENT OF ENERGY
under Contract DE-AC05-76RL01830
For open source projects, say how it is licensed. Copyright Battelle Memorial Institute 2025
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.