A machine vision tool for facilitating the optimization of large-area perovskite photovoltaics

We report a fast, reliable and non-destructive method for quantifying the homogeneity of perovskite thin films over large areas using machine vision. We adapt existing machine vision algorithms to spatially quantify multiple perovskite film properties (substrate coverage, film thickness, defect density) with pixel resolution from pictures of 25 cm2 samples. Our machine vision tool—called PerovskiteVision—can be combined with an optical model to predict photovoltaic cell and module current density from the perovskite film thickness. We use the measured film properties and predicted device current density to identify a posteriori the process conditions that simultaneously maximize the device performance and the manufacturing throughput for large-area perovskite deposition using gas-knife assisted slot-die coating. PerovskiteVision thus facilitates the transfer of a new deposition process to large-scale photovoltaic module manufacturing. This work shows how machine vision can accelerate slow characterization steps essential for the multi-objective optimization of thin film deposition processes.


INTRODUCTION
The efficiencies of perovskite-based photovoltaic devices (17.9% for 802 cm 2 devices) are approaching those of crystalline silicon devices (20.4% for 14800 cm 2 devices) 1 , but the device areas are not 2,3 . One key challenge in fabricating larger perovskite modules is finding a solution-coating method that yields homogeneous perovskite crystallization over large-area substrates [4][5][6][7] . The ability to use "slot-die coating" to deposit films over large areas, for example, would be highly advantageous due to the highthroughput and efficient material use that can be achieved [8][9][10] . To control the crystallization of slot-die coated perovskite films, a gas-knife directs a stream of nitrogen gas onto the wet perovskite precursor to locally trigger nucleation [11][12][13][14] . With this "gasquenching" method, slot-die coated mini modules can be made with 19.4% efficiencies 15 . During the slot-die coating process, the gas-knife can mechanically deform the wet precursor film and create drying inhomogeneities such as thickness variations, cracks and pinholes. To avoid the formation of morphological defects and to control the final perovskite film thickness, careful optimization of many coating parameters 16,17 is therefore required as it remains challenging to obtain homogeneous perovskite films with this technique.
A major factor limiting the ability to make homogeneous perovskite films by slot-die coating is the inability to quickly quantify the homogeneity of the films. A method for rapidly characterizing the homogeneity of these large-area perovskite layers is necessary for process optimization. Few tools are available for characterizing perovskite layer properties for largearea samples. Optical spectra and X-ray diffraction (XRD) patterns, for example, are typically measured on sample areas smaller than a few mm 2 . Standard stylus profilometry instruments can measure areas up to 225 cm 2 , but the measurement is destructive and the acquisition time scales with device area and thus goes up dramatically when working on large samples 18,19 . After perovskite films have been integrated into devices, techniques such as electroluminescence and light-beam-induced current can provide spatially resolved information over large areas 20 , but device preparation is time consuming. For these and other reasons, researchers must often evaluate the perovskite film homogeneity by either cutting large-area substrates into smaller pieces for individual characterization, or by relying on manual visual inspection alone.
Manual visual inspection is arguably the most effective method for characterizing large-area perovskite films because it requires no equipment and is fast. This method is highly subjective, however, which makes it difficult to identify trends in film morphology. This limitation motivated us to examine how the visual inspection of perovskite films could be automated and made quantitative using machine vision.
The present work builds on previous work applying machine vision and machine learning techniques to the study of silicon photovoltaics, thin films and bulk perovskite materials. For example, machine vision techniques can detect scratches, cracks, dirt and other defects in color or electroluminescence images of silicon photovoltaic devices [21][22][23][24][25] . Liu and coworkers provide a recent survey of the use of machine vision for inspecting silicon photovoltaics 23 . Machine vision techniques can also quantify the thickness of thin film materials and detect morphological defects such as pinholes, cracks and dewetting [26][27][28][29][30] . Machine vision-assisted imaging can also provide rapid, non-contact and spatially resolved information on the homogeneity of entire thin film samples to facilitate large-area film quality control [30][31][32][33] . While machine learning has been used to optimize perovskite compositions for performance and stability 34,35 , there has been less focus on leveraging machine learning or machine vision to optimize perovskite processing strategies. One notable example employed a convolutional neural network to detect the formation of bulk perovskite crystals as part of an automated workflow for optimizing antisolvent crystallization conditions 36 . The utility of machine vision for silicon photovoltaics and the need for optimized large-area perovskite film deposition techniques motivate the creation of machine vision tools tailored to the analysis of the perovskite film morphologies.
In this work, we combine machine vision with white light photography to extract quantitative information relevant to the optimization of a large-area perovskite film deposition process. We demonstrate our machine vision inspection method by using it to build comprehensive maps linking slot-die coating process parameters (wet film thickness, gas knife speed) to perovskite film properties (substrate coverage, film thickness and defect density). We then combine the thickness map with an optical model 37,38 to generate a map of predicted device current density. These maps enable the identification of optimal process conditions that simultaneously maximize coating throughput, film quality and predicted device current density. PerovskiteVision and the optical model also enable the generation of spatially resolved cell and module current density predictions. We experimentally validated these predictions for devices with absorbers deposited by slot-die coating using the previously identified optimal process conditions. In this way, we show how applying machine vision to the inspection of perovskite films can assist in the multi-parameter multi-objective optimization of large-area perovskite film deposition processes and devices.

Image-based substrate coverage quantification
We used gas-knife-assisted slot-die coating (Fig. 1a) to deposit a range of Cs 0.16 FA 0.84 Pb(I 0.88 Br 0.12 ) 3 (FA is the formamidinium ion) films 39 on 5 cm × 5 cm SnO 2 -coated ITO glass substrates. This coating process employs a slot-die coating head to deposit a wet film of precursor ink onto a substrate. A gas-knife that follows the slot-die coating head then triggers perovskite crystallization by directing a stream of nitrogen onto the wet precursor film 11,12,40 . Our samples exhibited varying degrees of substrate coverage depending on the deposition conditions. Under certain conditions, the substrate was fully covered by a smooth, brown perovskite layer (average roughness~12 nm). In many cases, however, the perovskite did not crystallize homogeneously, yielding samples with partial coverage and rough morphologies (e.g., micrometer-scale thickness and roughness variations) (Fig. 1b). Supplementary Fig. 1 shows profilometry scans for both the smooth and rough morphologies. The non-continuous perovskite films obtained can cause short circuits in devices and are not suitable for device fabrication.
We characterized the perovskite films using white-light photography (see Methods). We then manually annotated regions of full, partial or no coverage on a subset of the images (~10%). Finally, we used the annotated images to train a convolutional neural network (CNN) based on the existing VGG16 architecture 41 to segment the raw images into areas of full, partial and no coverage. Our model successfully distinguishes these various types of regions in seconds without human intervention. Figure 1c shows an example of the segmentation performed by the neural network. We used the covered area of the segmented images as the area of interest for subsequent analysis. We chose to express the substrate coverage ratio as the ratio between the covered area and the total coated area. Over the course of a typical process optimization campaign, we observed a progressive rise in the substrate coverage ratio ( Supplementary Fig. 2).
Image-based film thickness quantification Perovskite film thickness variations affect solar cell efficiency and are undesirable. To assist in the control of film thickness, we extended our CNN model to estimate the perovskite film thickness with pixel resolution (1 pixel = 10 µm × 10 µm) within the covered area. The thickness was estimated from the color data at each pixel using a calibration curve obtained from profilometry measurements performed on 11 spin-coated perovskite reference samples. These samples had thickness ranging from 160 nm to 550 nm (see Methods and Supplementary Fig. 3). As some of our slot-die coated perovskite samples had regions with thicknesses outside of this 160-550 nm calibration range, we extrapolated the calibration curve for thicknesses exceeding 550 nm when necessary. Extrapolated thickness values never exceeded 800 nm and were not used for any of the current-density predictions described below. After calibration on only 11 samples, our CNN model provided pixel-by-pixel thickness maps in the covered area for our entire dataset of over 500 slot-die coated samples (Supplementary Tables 2 and 3). Fig. 1d shows the thickness map of the sample pictured in Fig. 1b.

Image-based morphological defect quantification
In addition to quantifying film thickness variations, it is also important to quantify morphological defects present in a perovskite film prior to device fabrication to assess the potential performance loss in the completed device 42 . We therefore developed an unsupervised model based on the work of Jeon and coworkers 43 to detect and quantify defects in the region of interest where the substrate is fully covered by the perovskite film. The resulting defect map (e.g., Fig. 1e) clearly matches the morphological defects visible in the thickness map. This defect map enables a variety of defect metrics to be calculated, such as the fraction of the entire covered area of the sample containing morphological defects (see Methods), or the total area of defects. Areas containing defects are unlikely to contribute to device current generation.
Identification of favorable slot-die coating parameters We next applied PerovskiteVision to optical images of perovskite films fabricated with various process conditions while optimizing the gas-knife assisted slot-die coating process. We focused on two main process parameters: the gas-knife speed and the wet precursor film thickness. The gas-knife speed was manipulated directly, whereas the wet film thickness is a theoretical quantity controlled by the ink dispense rate, the coating speed and the substrate width (see Supplementary Discussion). We selected 12 slot-die coated samples fabricated using nine gas-knife speeds to illustrate how the process parameters controlled the substrate coverage ratio, the mean film thickness and the defect density ( Fig. 2).
At reduced gas-knife speed (15-19 mm.s −1 ), both thin and thick wet films crystallized homogeneously, resulting in substrate coverage ratios over 60% (Fig. 2a). At intermediate gas-knife speeds (21-23 mm.s −1 ), the substrate coverage dropped and the film mean thickness increased. We attribute this trend to the presence of thicker but fewer well crystallized areas on the substrate. At higher gas-knife speeds (33 mm.s −1 ), the mean film thickness increased (Fig. 2b), as did the area of defects (Fig. 2c). The combination of thick wet film and low gas knife speed led to the largest area of defects of 1.5% (16 mm.s −1 , 1.8 µm, Fig. 2c). Overall, we identified three samples where the substrate coverage ratio was over 60% and the defect density was low: A (v gas-knife = 15 mm.s −1 ; t wet film = 2 µm), B (v gas-knife = 28 mm.s −1 ; t wet film = 1.2 µm) and C (v gas-knife = 15 mm.s −1 ; t wet film = 0.45 µm).
Device photocurrent prediction using an optical model The perovskite film properties (thickness, defects) extracted from images using PerovskiteVision were then linked to photovoltaic device performance using a separate, physics-based optical model (Fig. 3). This model predicts an upper bound on the device photocurrent density (J sc ) for a given perovskite film thickness 37,38,44,45 assuming an internal quantum efficiency (IQE) of 100%.
The model employs the transfer matrix formalism 44,45 and the optical indices and thicknesses of each layer in the device stack (see inset of Fig. 3a). This optical model assumes spatially homogeneous optical properties (i.e., refractive index and extinction coefficient are assumed to be the same at all positions in the film). We obtained values for the optical properties of each layer using a set of ellipsometry measurements (see Methods). We used Fig. 1 Machine vision workflow for quantifying large-area perovskite film morphology from optical images using the PerovskiteVision tool. a Schematic of the slot-die coating process, which involves coating of a wet precursor film onto a substrate followed by gas-knifeassisted crystallization. b Typical photograph of perovskite layer slot-die coated on 5 cm × 5 cm substrate. A total of 504 slot-die coated samples were imaged in this study. c Components of the PerovskiteVision tool for analyzing images of perovskite films. d Substrate coverage map. Areas of full substrate coverage are shown in red, the blue areas indicate partial substrate coverage and the green areas indicate the absence of perovskite film. e Thickness map extracted from the image color of the 5 cm × 5 cm substrate using experimentally calibrated regression ( Supplementary Fig. 9). f Defect map. White pixels contain morphological defects such as cracks or pinholes. Scale bars indicate 1 cm. g The outputs of PerovskiteVision are combined with a physics-based optical model to predict photovoltaic device current density. These predictions enable the identification of favorable slot-die coating parameters.
the optical properties obtained from ellipsometry data on 350 nm thick spin-coated perovskite films as approximate values for all the perovskite films studied. We account for lateral variations in the perovskite film thickness by applying the optical model at each 10 µm × 10 µm pixel of the film thickness map generated by PerovskiteVision. A current density of zero was predicted for uncovered pixels.

Model validation for devices with spin-coated absorbers
To validate the optical model, we fabricated validation devices using spin-coated perovskite films with a range of absorber thicknesses (160, 250, 350, 550 nm) (Fig. 3a). These devices employed the following structure: glass|ITO|SnO 2 |perovskite|PTAA| Au (see inset of Fig. 3a). The optical model fits the experimental data for the calibration devices well except for the devices with the thinnest absorber layers (160 nm). For these devices, the measured current density (J sc ) values were lower than the values predicted by the model (see Fig. 3a and Supplementary Fig. 4). Our observation of low J sc values for devices with absorbers thinner than 200 nm is consistent with the literature 46,47 . We attribute these lower-than-predicted experimental J sc values to variations in the absorber optical and electronic properties caused by the presence of PbI 2 impurities in our films. Specifically, PbI 2 impurities do not contribute to visible light absorption and could therefore reduce the overall extinction coefficient of the absorber 48 . Moreover, PbI 2 impurities can hinder charge transport 49 when present in amounts greater than 6-9 mol% relative to the perovskite phase 50,51 . The effects of PbI 2 impurities are not accounted for by our optical model. Variations in the optical and electronic properties of the absorbers caused by lead iodide may therefore reduce the experimentally measured device current densities below the upper bound predicted by our optical model.
While we observed PbI 2 XRD peaks for every absorber thickness ( Supplementary Fig. 5a), these impurities were likely to affect our 160 nm devices more than the thicker devices for two reasons: (1) the 160 nm thick absorber exhibited the largest ratio of crystalline PbI 2 to perovskite XRD peak area (see Supplementary Fig. 5b); and, (2) devices with thinner absorber layers are more sensitive to variations in the absorber extinction coefficient 46 . These observations highlight a limitation of our approximation that the optical properties of all the perovskite layers studied are the same as the 350 nm films used to build the model. This approximation, however, enables the rapid generation of current density estimates for spin-coated films of varying thicknesses without additional optical property measurements. As we show below, this approximation also enables current density predictions for devices with slot-die coated absorbers.
Optimal slot-die parameters based on predicted photocurrent Next, we used the calibrated optical model to predict device current density as a function of the slot-die coating parameters (i.e., gas-knife speed and wet film thickness) used during perovskite film deposition (Fig. 3b). The economics of perovskite photovoltaic module manufacturing using slot-die coating are improved by increasing the process speed, fabrication yield and device performance. Maximizing gas-knife speed, minimizing defect density and maximizing device current density are important steps towards achieving these high-level objectives. We used these categories to compare the samples A, B, and C using the process outcome maps given in Figs. 2 and 3b. Sample B was fabricated using the larger gas-knife speed (28 mm.s −1 ). The defect density of all three samples was comparable (Fig. 2c). Sample B led to the highest J sc simulated value~22.7 mA.cm −2 due to its optimal film thickness. In summary, PerovskiteVision facilitated the selection of the process parameters used to create sample B (gas-knife speed = 28 mm.s −1 , wet-film thickness = 1.2 µm) as the best among several candidates.
Model validation for devices with slot-die coated absorbers We next applied PerovskiteVision to the analysis of photovoltaic cells in which the perovskite layer was slot-die coated using the favorable deposition parameters used to create sample B (see Fig.  3c-g). As different solution processing methods can yield different perovskite film morphologies 52 , we used SEM to compare the morphology of the resulting 550 nm thick slot-die coated film to that of the 350 nm thick spin-coated film on which the optical model was based. The spin-coated and slot-die coated films exhibited comparable morphologies ( Supplementary Fig. 11). We therefore continued to use the optical properties of the 350 nm thick spin-coated films as approximate values for all the films studied, including the slot-die coated films.
We optically imaged the 550 nm thick slot-die coated film before device fabrication to enable analysis of the film regions which are later hidden by the deposition of electrodes. These regions are important because they become the device active areas. We fabricated 6 devices on the 5 cm × 5 cm slot-die coated substrate (Fig. 3e). Based on the image of the sample before device fabrication, we generated a perovskite film thickness map for the active area of each of the six devices ( Supplementary Fig.  6). We then used the optical model to convert these thickness maps into spatially resolved J sc maps for each device (Fig. 3f). These current density maps also account for regions of poor perovskite coverage using the coverage segmentation (Fig. 3d). Specifically, only regions classified as fully covered contribute to the predicted current generation (see device 3).
The correlation between the experimental and predicted average device current densities is shown in Fig. 3g. Our approach produces accurate J sc predictions for devices 3, 4, and 5, which Fig. 2 Linking the slot-die coating process parameters to the perovskite film morphology. a Substrate coverage ratio extracted from 12 slot-die coated perovskite film images during process optimization, defined as the ratio between the covered area and the total coated area. b Mean thickness of the perovskite films. c Area of defects, calculated as the ratio of defect area (white pixels) to covered area. exhibit relatively ideal JV curves (see inset to Fig. 3g). These results show that PerovskiteVision can predict an accurate upper bound on J sc, which takes into account lateral inhomogeneities in the perovskite film (i.e., thickness variations and regions of partial coverage). Our approach, however, overestimates the experimental J sc for devices 2 and 6 (see Supplementary Table 6). This illustrates a limitation of our approach-it does not account for other types of non-idealities that may reduce device performance by impacting the open-circuit voltage or fill factor.

Prediction of current density for photovoltaic modules
PerovskiteVision can also be applied to predicting the current density of perovskite photovoltaic modules (Fig. 4). A module consists of several cells electrically connected in series [53][54][55] . The presence of morphological inhomogeneities in any of the cells may limit the overall module performance. The position of the module active area on a perovskite film containing morphological defects can therefore strongly influence the resulting device performance. Here, we use PerovskiteVision to assess a candidate area for module fabrication on a perovskite film before fabricating the module. This is achieved by using the tools described above to convert an image of a perovskite film (Fig. 4a) into a current density map of the sample (Fig. 4b) and by subsequently analyzing this map within the designated module area.
We used PerovskiteVision to analyze a hypothetical 4 cm × 4 cm module consisting of eight rectangular sub-cells (Fig. 4c). Fig. 3 Prediction of the device current density (J sc ) from the perovskite film thickness using an optical model. a Experimental validation of the optical model using spin-coated devices fabricated from perovskite films with various thicknesses (see also Supplementary Fig. 4). Inset: Stack used for the optical model and device fabrication (see Methods). b Map of predicted device J sc for different process conditions. This map was generated by applying the calibrated optical model to the perovskite thickness map given in Fig. 1g. High-performing samples are indicated with letters A, B, and C. c-g Application of PerovskiteVision and of the optical model to predict spatially resolved current density for slot-die coated devices fabricated using the same process conditions as used for sample B. c is an image of the slot-die coated perovskite film, d shows the segmentation of this image into fully covered, partially covered and uncovered areas. e shows where six devices (each of nominal active area 0.33 cm 2 ) were fabricated on the sample. Scale bars indicate 5 cm. f shows a spatially resolved current density prediction for each device. This prediction is made by combining the coverage map and the thickness map with the optical model. Note that this causes device #3 to have a region of zero current density. Device #1 also has a region of zero current density due to an incomplete top electrode. g Correlation between the simulated and experimental device current density. JV curves for each device are shown in the inset. *Device #1 had an incomplete top electrode and was measured under different conditions than the other devices. The results from this device are therefore not comparable to those from the other devices.
The active area chosen for the hypothetical module contained some pinholes, cracks and thickness variations (Fig. 4a, b and Supplementary Fig. 7). These morphology variations resulted in spatial inhomogeneity in the predicted current density (Fig. 4c). The predicted current of cell #4 was lower compared to the other cells (Fig. 4d). The low predicted current for cell #4 was caused by the presence of a pinhole in the perovskite film that did not contribute to the current generation. Owing to the series connection of the cells, the total current of a module is determined by the cell with the lowest current 54 . The incorporation of the defective cell #4 into the hypothetical module analyzed here would therefore reduce the overall module performance. This scenario illustrates how the information provided by PerovskiteVision enables a researcher to choose an alternative module position or design to obtain a higher-performing module.

DISCUSSION
Here, we used machine vision to extract quantitative morphological data from images of large-area perovskite thin films. While the substrate coverage of a sample is usually assessed only by visual inspection and seldom quantified, our approach makes coverage quantification as easy as capturing a photograph. From a single picture, PerovskiteVision extracts a holistic set of metrics about the sample: substrate coverage ratio, perovskite mean thickness and defect density. While profilometry provides reliable thickness data, this method is slow, requires the creation of stepedges and only reports the thickness at measured points. The image-based thickness estimation and morphological defect detection reported here can complement profilometry by providing fast, non-contact measurement with a nominal 10 µm × 10 µm lateral resolution over an entire 5 cm × 5 cm sample. While characterizing a large area sample by cutting it into pieces can require hours of work, our non-destructive method characterizes the whole sample at once and within minutes. Adapting our approach to larger substrates could provide rapid, pixel-level resolution of defects relevant to perovskite module manufacturing quality control.
The information provided by PerovskiteVision can help increase research output by enabling high-quality samples (or sample regions) to be selected for device or module fabrication based on quantitative proof instead of qualitative visual inspection. During process optimization, this inspection tool facilitates the creation of quantitative maps linking process parameters to experimental outcomes. These maps facilitate the challenging multi-parameter, multi-objective optimization required to develop candidate manufacturing processes.
Here, we estimated the perovskite film thickness by fusing profilometry data with images of the perovskite films. We then used an optical model to predict current density from the film thickness estimates under the approximation that all the perovskite films had the same refractive index and extinction coefficient as our 350 nm thick calibration sample. To improve the optical model accuracy, sample-to-sample variations in the refractive index and extinction coefficients of the perovskite films could be accounted for by fusing additional measurements (e.g., ellipsometry) with the image data. Photoluminescence imaging could also provide a deeper opto-electronic quality assessment of the perovskite/substrate interface and inform more sophisticated device performance predictions.
Other variations on the methods described here could also be useful for perovskite research. For instance, visual and X-Ray diffraction signatures of perovskite degradation could be fused to compare the stability of different materials 56 or the efficacy of various encapsulation strategies 57,58 . When brightfield photography in transmission cannot be used (e.g., with opaque substrates), Fig. 4 Predicting perovskite photovoltaic module current density using PerovskiteVision. a Picture of a slot-die coated perovskite film with high coverage ratio but containing morphological defects such as cracks and pinholes. b Map of the predicted photocurrent density over the entire sample. This map is generated by applying the optical model to the perovskite film thickness map. Scale bars indicate 5 cm. c Map of predicted photocurrent density for an 8-cell photovoltaic module that could be fabricated using the perovskite sample shown in panel a. d Average predicted current density for each of the eight cells of the module. The average and minimum J sc across all eight cells are shown in orange and blue, respectively. The module current density would be limited by the current density of the worst-performing cell (in blue), predicted in this case to be cell #4, which contains a large pinhole.
one could employ reflection imaging or replace white light imaging with photoluminescence or hyperspectral imaging 20 . The application to opaque substrates is particularly relevant to facilitate quality control during perovskite/silicon tandem solar cell fabrication 59 .
In summary, we applied machine vision to images of large-area slot-die coated perovskite films to quickly extract pixel mappings of substrate coverage, perovskite film thickness and defect density values over 5 cm × 5 cm substrates. We used an optical model to estimate device current density from the extracted perovskite film thickness, taking losses due to morphological inhomogeneities into account. This approach facilitated the multi-parameter, multiobjective optimization of a gas-knife assisted slot-die coating process by reducing the effort required to characterize the samples produced at each process condition. The spatially resolved current density predictions provided by PerovskiteVision can help researchers select the best samples or the best regions within inhomogeneous samples for cell or module fabrication. Machine vision tools such as PerovskiteVision can provide multiple types of film quality feedback to support techno-economic decision making by process developers. This tool could also be used for on-line feedback in manufacturing settings or autonomous laboratories 60,61 . In particular, the multiple streams of information provided by PerovskiteVision could be employed in algorithmically guided experimentation that models multiple photovoltaic device properties 62 or employs multi-objective optimization algorithms 63,64 . Machine vision tools like Perovskite-Vision have the potential to facilitate the quality control of largearea films and the optimization of deposition processes in the solar industry and beyond.

Device fabrication
The 5 cm × 5 cm ITO substrates (~7 ohms per square) were cleaned by sonication in acetone, isopropanol and deionized water, before being dried by a nitrogen gun and then transferred to a 100°C oven overnight for further drying.

Deposition of electron transport layer
For SnO 2 compact layer deposition, a nanoparticle solution was dissolved in deionized water at 3% w and the prepared solution was spin coated at 2400 rpm for 2 s followed by 4000 rpm for 40 s. The obtained layer was annealed at 80°C for 1 min in air and used, after cooling, for perovskite coating.

Deposition of perovskite layer
The perovskite precursor ink was prepared in a nitrogen-filled glovebox by mixing PbI 2 , FAI, PbBr 2 and CsI in a DMF:DMSO (4:1 ratio) solvent to obtain 0.6, 0.9, 1.2, and 1.5 M solutions with the following formula: Cs 0.16 FA 0.84 Pb (I 0.88 Br 0.12 ) 3 and 6% Pb excess. This solution was held at 40°C overnight under magnetic stirring.

Spin-coating
The thickness calibration was performed on spin-coated perovskite layers quenched using the anti-solvent method. For those samples, the perovskite precursor solution was deposited onto the substrate, using a 3-step spin-coating protocol: 200 rpm for 5 s, 1000 rpm for 10 s and finally 6000 rpm for 20 s. During the final step, 700 µL of chlorobenzene was dropped on the substrate 8 s prior to the end of the protocol.
The crystallization was completed by post annealing at 100°C for 1 h in a nitrogen atmosphere.

Slot-die coating
The precursor solution was transferred to the slot-die tubing system one day after preparation in a glove box. A TC300 slot-die coater (Automatic Research) was used to coat the perovskite layers onto the substrates. The slot-die coating process consisted of a meniscus-assisted deposition of a wet precursor film onto the substrate at a given coating speed (typically 28 mm.s −1 ), ink volume dispense rate (100 µL.min −1 ) and coating gap (100 µm), defining a theoretical wet film thickness from 1 to 4 µm on a 5 cm wide substrate. The system was modified by the addition of a gas-knife, which was fixed to the slot-die coating head at a height of 3 mm above the substrate. The gas-knife was connected to a nitrogen cylinder. The gas flow rate was fixed to 110 L.min −1 . The gas-knife speed is fixed to the slot-die coating head; its velocities range from 5 to 33 mm.s −1 during the slot-die coating process. The role of the gas-knife in crystallization is to quickly dry the precursor film with a stream of nitrogen gas [11][12][13] . The substrate platform controls the substrate temperature during coating from 25°C to 100°C. The slot-die coating process was conducted in an enclosed environment with humidity set to 20-30% RH. Once the perovskite layer coated, the substrates were stored in an ambient atmosphere (RH~40 %) before characterization.

Characterization
A purpose-built imaging system (Olympus DP70 microscope digital camera connected to DP controller and DP manager software) was used to take bright field photographs (Coherent Inc lamp ML-0405, cold cathode fluorescent lamp) of the samples on a luminous background with the following settings: size 4080 pixel × 3072 pixel, exposure time of 1 s, ISO of 200 and ×40 magnification. Film thicknesses were measured using a Bruker Dektak profilometer. For calibration, 9 measurement points were used on 5 × 5 cm substrates.

Segmentation
The training, validation and test of the CNN models for the substrate coverage quantification were performed using images from various batches of slot-die coated perovskite films deposited using the slot-die coating process described above. First, 42 pictures from four batches were manually annotated to be used as a training set (Supplementary Table 3). Then, the remaining 448 images were used without annotation for validation and testing. In the first stage, we removed the black background of the images and then eliminated the white sections of the image to detect the total coated area. The total coated area was calculated using Eq. (1): In which A sample was the initial sample's surface area of 25 cm 2 .
We developed a segmentation model and used it to calculate the covered area, partially covered, and uncovered areas. The segmentation was conducted using a sliding window approach with window size of 50 pixels and 45 pixels overlapping 65 . We adapted a VGG16 41,66 based CNN model to classify each patch (i.e., the input for the CNN was of size 50 pixels × 50 pixels) into one of the covered, partially covered or uncovered areas. The CNN classifier structure is presented in Supplementary Fig. 8

Defect detection
We analyzed the extent of defects in the covered area using an unsupervised method derived from the work of Jeon and coworkers 43 . This method uses the Canny algorithm and an adversarial image-to-Frequency Transform to detect defects on a pixel-by-pixel basis. We employed this algorithm because it was reported to demonstrate outstanding unsupervised defect detection performance. We used the output of this defect detection algorithm to quantify the surface area of Thickness extraction from images using calibrated color data The perovskite film thickness was extracted from the images based on a calibration of the color data against profilometry data ( Supplementary Fig.  9). Profilometry calibration data and images were acquired on a set of spincoated perovskite films with thickness varying from 150 to 600 nm, corresponding to the typical perovskite film thickness range obtained by slot-die coating ( Supplementary Fig. 2). 135 thickness data points were measured at nine positions on each of 15 sample images ( Supplementary  Fig. 3a). The RGB and associated gray levels at the measured points were obtained from the images and mapped to the profilometry thickness data. The scatter plot shown in Supplementary Fig. 9 shows the non-linear regression between thickness and gray level. This regression equation and the averaged gray level of the pixels contained in the covered area were used to report a mean film thickness value for each sample. The thickness was reported for each pixel if it fell in the segmented covered area (Fig.  1d). This model was then applied on the 504 slot-die coated layers to generate thickness estimates in two forms: either localized for mapping purposes (Fig. 2b) or averaged for process optimization purposes (Fig. 3b).

Optical model for J sc prediction
Optical simulations were performed using the TransferMatrix_VaryThickness software provided for free by Stanford University 37,38 and run with Matlab. This software computes the current density using the transfer matrix formalism 44,45 . Input parameters consist of the thicknesses, measured by profilometry, and the optical indices of each layer composing the solar cell ( Fig. 3a-inset). We determined the latter by variable angle spectroscopic ellipsometry carried out at three different incident angles (50°, 60°, and 70°) with an energy range from 0.6 to 4 eV. Spectra were then fitted using common optical dispersion models for interface layers and electrodes. The perovskite layer was modeled by a triple amorphous dispersion law, so as to represent the three oscillators at the origin of each absorption peak in the UV-visible spectra 44,45 . To extract optical indices that are representative of the layers within the solar cell, measurements were performed on the following stacks: glass/ITO, glass/ITO/SnO 2 , glass/ITO/SnO 2 /perovskite and glass/ITO/SnO 2 /perovskite/PTAA. For the perovskite films, we used the properties obtained from ellipsometry data on 350 nm thick spin-coated perovskite films as approximate values for all the perovskite films studied. The output of the optical simulations is a curve of the current density as a function of the perovskite film thickness. The optical model curve obtained (Fig. 3a) was applied to estimate the device current density from perovskite film thickness.

Experimental measurement of J sc
Current-voltage curves of the photovoltaic devices were obtained using a solar simulator (Oriel 92190, Newport) connected to a multimeter (SMU 2602A, Keithley) and under standard AM 1.5G illumination (1600 W, Xenon lamp, Ushio). The scans were performed in the following conditions: Reverse scan 1.2 to −0.2 V, in ambient conditions and on a device active area of 0.33 cm 2 . The devices were measured 5 times in a row and the experimental error bars determined according to the standard deviation of the 5 measurement values. The experimental data are reported in Supplementary Tables 5 and 6 and Supplementary Fig. 10.

DATA AVAILABILITY
All data are available for non-commercial, research use only upon request from the corresponding author.

CODE AVAILABILITY
The PerovskiteVision code is available for non-commercial, research use only upon request from the corresponding author.