The present research deals with the detection of porosity defects in aluminum alloys using convolutional neural networks (CNNs). The goal of this research is to build a CNN model that can accurately predict porosity defects in light optical microscopy images. To train the model, images of polished samples of several aluminum alloys containing a significant number of defects were used: EN AC 46000 AlSi9Cu3(Fe), EN AC 43400 AlSi10Mg(Fe), EN AC 47100 AlSi12Cu1(Fe), EN AC 51400 AlMg5(Si), EN AC 42000 AlSi7Mg0.6, EN AC 42000 AlSi7Mg and EN AC-44300 AlSi12(Fe)(a). Various types of porosity defects were included. The proposed custom CNN structure performed excellently in the test set: it correctly classified 3,990 images and made errors in only 254 images. Thus, the classification accuracy achieved was 94%. In addition, the performance of the model was tested with all the alloys used during the training at the nominal magnification (50×\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$\times $$\end{document}) as well as with the EN AC 46000 AlSi9Cu3(Fe) alloys at different magnifications (50×\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$\times $$\end{document}, 100×\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$\times $$\end{document}, 200×\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$\times $$\end{document}, 400×\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$\times $$\end{document}, and 500×\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$\times $$\end{document}). Consequently, it is shown that deep learning models can be used to accurately predict porosity defects.