# Approach to Automated Visual Inspection of Objects Based on Artificial Intelligence
## 3 Visual Inspection Methodology and Data Processing Design
### Deep Neural Network Selection and Data Preparation  
For the purpose of Transfer Learning in this research, the AlexNet network was chosen [13]. The algorithm will take care of the classification of the selected area with the expected occurrence of the searched objects. The AlexNet network was created by [PERSON] under the leadership of [PERSON] in 2012. The network consists of 25 layers and ranks among convolutional deep neural networks. It is trained on 1,200,000 high-resolution images from the LSVRC-2010 ImageNet dataset, which divides into 1000 different categories [14; 28].  
As mentioned, the used network is pre-trained to determine up to 1000 categories of objects and in the case of the given task solved only six defect classes (CH01-CH06). Transfer Learning used without changing only the first 22 layers of the network. The last three layers, which were directly related to the number of classified classes, were changed according to the needs of the solved task. The layers that have been modified are \"fc8\" (Fully connected layer), \"prob\" (Softmax Layer) and \"output\" (Classification Layer).  
The images obtained from the industrial camera were of the size 2000 \(\times\) 3736 pixels after trimming the redundant areas and monochrome in the *.png format. These images had to be adjusted so that the input layer (\"data\") of the selected network could process them. The input layer of the AlexNet network requires data with parameters 227 \(\times\) 227 \(\times\) 3. This means that the resolution of images entering for network processing should be 227 \(\times\) 227 pixels, and the network requires three-channel RGB images. In view of these facts, the input data had to be adjusted to meet these conditions. For this purpose and also for the purpose of training data quantity enlarging, the imageAugmenter function and the gray2 rgb function were used.  
The input layer of the network requires images with certain parameters and also the used detector receives only a certain type of data. In the case described, the data entering the detector must be in the form of a table, in this case with two columns. The first column represents the path to the image on the disk and the second column consists of four values that define the location of the bounding box of the searched objects created in the \"Image Labeler\" application.  
The aforementioned application allows you to upload images from a specified folder on the hard disk and use one of three methods (defining frames, lines and marking individual pixels), define areas where the searched objects occur, and thus prepare the input data for learning. The output from the object marking application is a file in *.mat format and contains the so-called \"Ground Truth\" which represents the aforementioned designations of areas of interest in the pictures. In the program, these labels are stored in the Truth variable. In order to be able to use this data together with images for detection, it was necessary to use the combine function, which was used to create a combined data repository with images and the corresponding values of the location of the boundary frames of the elements. Subsequently, a table was created using the objectDetectorTrainingData function, which was used as input data for the detector.