This study uses explainable AI to analyze photoluminescence data from perovskite thin-film processing, linking it to solar cell performance, and offering actionable insights for scalable solar cell manufacturing.
Abstract:
Large-area processing of perovskite semiconductor thin-films is complex and evokes unexplained variance in quality, posing a major hurdle for the commercialization of perovskite photovoltaics. Advances in scalable fabrication processes are currently limited to gradual and arbitrary trial-and-error procedures. While the in-situ acquisition of photoluminescence videos has the potential to reveal important variations in the thin-film formation process, the high dimensionality of the data quickly surpasses the limits of human analysis. In response, this study leverages deep learning and explainable artificial intelligence (XAI) to discover relationships between sensor information acquired during the perovskite thin-film formation process and the resulting solar cell performance indicators, while rendering these relationships humanly understandable. We further show how gained insights can be distilled into actionable recommendations for perovskite thin-film processing, advancing towards industrial-scale solar cell manufacturing. Our study demonstrates that XAI methods will play a critical role in accelerating energy materials science.
If you use perovskite-xai please cite our paper
@article{https://doi.org/10.1002/adma.202307160,
author = {Klein, Lukas and Ziegler, Sebastian and Laufer, Felix and Debus, Charlotte and GΓΆtz, Markus and Maier-Hein, Klaus and Paetzold, Ulrich W. and Isensee, Fabian and JΓ€ger, Paul F.},
title = {Discovering Process Dynamics for Scalable Perovskite Solar Cell Manufacturing with Explainable AI},
journal = {Advanced Materials},
volume = {n/a},
number = {n/a},
pages = {2307160},
keywords = {deep learning, energy materials science, explainable artificial intelligence (XAI), knowledge discovery, perovskite solar cells},
doi = {https://doi.org/10.1002/adma.202307160},
url = {https://onlinelibrary.wiley.com/doi/abs/10.1002/adma.202307160},
eprint = {https://onlinelibrary.wiley.com/doi/pdf/10.1002/adma.202307160},
}
perovskite-xai requires Python version 3.9 or later. All essential libraries for the execution of the code are provided in the requirements.txt
file from which a new environment can be created (Linux only):
git clone https://github.com/IML-DKFZ/repo
cd perovskite-xai
conda create -n perovskite-xai python=3.9 --file requirements.txt
source activate perovskite-xai
Depending on your GPU, you need to install an appropriate version of PyTorch and torchvision separately. All scripts run also on CPU, but can take substantially longer depending on the experiment. Testing and development were done with the Pytorch version using CUDA 11.6.
βββ base_model.py - Pytorch Ligthning Module defining the training pipeline
βββ data
β βββ augmentations - Augmentation policies for the 1/2/3 dimensional representations
β βββ perovskite_dataset.py - Pytorch Dataset Definition of the different representations
βββ main.py - Entry point incl. CLI for training a model on the perovskite data
βββ models
β βββ resnet.py - ResNet implmentations for 1/2/3 dimensional inputs
β βββ slowfast.py - SlowFast implementation
βββ predict_testset.py - Evaluation of the trained models on the held out testset
βββ requirements.txt - Requirements file for running the code
βββ utils.py - Multiple utility functions for model loading, logging etc.
βββ xai
βββ images - Figure export location
βββ results - Interim data export location
βββ src
β βββ attribution - Attribution computation & visualization
β βββ counterfactuals - CF computation & visualization
β βββ evaluation - Evaluation computation & visualization
β βββ tcav - TCAV computation & visualization
βββ utils - util scripts for evaluation
βββ util_vis
βββ util_error_vis.ipynb - Residual and parity plots
βββ util_vis.ipynb - Various paper figures
The dataset can be downloaded here.
Follow the instructions to preprocess the data and obtain the videos as numpy arrays with respective labels saved in csv files. The train test split as well as the Cross Validation splits are similar to what is used here. All data representations are generated on the fly within the respective dataloaders. No further preprocessing is necessary.
Pretrained model weights are available here: Weights
Click here for the exact commands to reproduce the training of each model.
Label: PCE
Point Timeseries
python main.py ResNet152 --epochs 1000 --scheduler CosineAnneal --lr 0.0001 --optimizer Madgrad --batch_size 256 --data Perov_1d --wd 0 --save_model --chpt_name mP_1D_RN152 --target PCE_mean --norm_target --use_all_folds
Image in-situ
python main.py ResNet18 --epochs 1000 --scheduler CosineAnneal --lr 0.0001 --optimizer Madgrad --batch_size 256 --data Perov_2d --wd 0 --augmentation baseline --save_model --chpt_name mP_2D_RN18 --target PCE_mean --norm_target --use_all_folds
Image ex-situ
python main.py ResNet18 --epochs 1000 --scheduler CosineAnneal --lr 0.0001 --optimizer Madgrad --batch_size 256 --data Perov_2d --wd 0 --augmentation aug2 --save_model --chpt_name mP_2D_exsitu_RN18 --target PCE_mean --norm_target --use_all_folds --ex_situ_img
Vector Timeseries
python main.py ResNet18 --epochs 1000 --scheduler CosineAnneal --lr 0.000005 --optimizer AdamW --batch_size 256 --data Perov_time_2d --wd 0 --augmentation aug3 --save_model --chpt_name mP_2D_time_RN18 --target PCE_mean --norm_target --use_all_folds
Video
python main.py SlowFast --epochs 1000 --scheduler CosineAnneal --lr 0.001 --optimizer AdamW --batch_size 256 --data Perov_3d --wd 0 --augmentation aug1 --save_model --chpt_name mP_3D_SF --target PCE_mean --norm_target --use_all_folds
Label: mean Thickness
Point Timeseries
python main.py ResNet152 --epochs 1000 --scheduler CosineAnneal --lr 0.0001 --optimizer Madgrad --batch_size 256 --data Perov_1d --wd 0 --target meanThickness --use_all_folds --save_model --chpt_name mT_1D_RN152
Image in-situ
python main.py ResNet18 --epochs 1000 --scheduler CosineAnneal --lr 0.0001 --optimizer Madgrad --batch_size 256 --data Perov_2d --wd 0 --augmentation baseline --target meanThickness --use_all_folds --save_model --chpt_name mT_2D_RN18
Image ex-situ
python main.py ResNet18 --epochs 1000 --scheduler CosineAnneal --lr 0.0001 --optimizer Madgrad --batch_size 256 --data Perov_2d --wd 0 --augmentation baseline --target meanThickness --use_all_folds --save_model --chpt_name mT_2D_exsitu_RN18 --ex_situ_img
Vector Timeseries
python main.py ResNet18 --epochs 1000 --scheduler CosineAnneal --lr 0.01 --optimizer AdamW --batch_size 256 --data Perov_time_2d --wd 0 --augmentation aug3 --target meanThickness --warmstart 0 --use_all_folds --save_model --chpt_name mT_2Dtime_RN18
Video
python main.py SlowFast --epochs 1000 --scheduler CosineAnneal --lr 0.001 --optimizer AdamW --batch_size 256 --data Perov_3d --wd 0 --augmentation aug1 --target meanThickness --use_all_folds --save_model --chpt_name mT_3D_SF
Feature Importance
Open the folder ./xai/src/attribution
. This folder contains ipython notebooks for attribution computation and attribution visualization. There is one notebook per modality and for local or global attribution computation (global attribution only if possible for this modality). The paths to the respective model weights and datasets have to be set. Further the respective target (target = "mth" or "pce"
) has to be selected. Global attribution computation (n=100) and the rendering of the GIF for 3D Video attribution can take some time.
Counterfactual Examples
Open the folder ./xai/src/counterfactuals
. This folder contains ipython notebooks for CF computation and visualization. There is one notebook per modality and the paths to the respective model weights and datasets have to be set. The default selected observations to compute and visualize the CF is the one shown in the paper. Further the respective target (target = "mth" or "pce"
) has to be selected. The computation for 3D video CFs can take substantial time. Thus the results are exportet into the ./xai/results
folder before (GIF) visualization.
TCAV
Run the script ./xai/src/tcav/tcav_1D.py
with the data_dir
, checkpoint_dir
and target
arguments submitted to the parser. For example:
python ./xai/src/tcav/tcav_1D.py --data_dir="path/to/data" --checkpoint_dir="path/to/checkpoints" --target="mth"
The script runs the whole TCAV pipeline:
- Concept sampling
- Linear model training and CAV extraction
- CAV testing on selected model layers
- Figure creation and export
Open the folder ./xai/src/evaluation
. In this folder are four scripts for the evaluation of the attribution maps for each modality. Set the data_dir
and checkpoint_dir
among other hyperparameter in the argument parser when running the scripts. For example:
pyhton ./xai/src/evaluation/eval_1D --data_dir="path/to/data" --checkpoint_dir="path/to/checkpoints" --batch_size=500 --target="pce"
The script computes the attribution maps and evaluates them for n = batch_size
observations. The results are exportet as .npz
compressed arrays to ./xai/results/
. The results can be visualized by the eval_plot.ipynb
notebook. Only the target (target = "mth" or "pce"
) and modality (dim = "1D", "2D_time", "2D_image" or "3D") have to be specified.
The code is developed by the authors of the paper. However, it does also contain pieces of code from the following packages:
- Captum by Kokhlikyan, Narine et al.: https://github.com/pytorch/captum
- DiCE by Mothilal, Ramaravind K. et al.: https://github.com/interpretml/DiCE
- Image Classification by Ziegler, Sebastian: https://github.com/MIC-DKFZ/image_classification
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β
perovskite-xai is developed and maintained by the Interactive Machine Learning Group and the Applied Computer Vision Lab of Helmholtz Imaging and the DKFZ, as well as the Light Technology Institute of the Karlsruhe Institute of Technology and Helmholtz AI.