## 3 Analysis of the System
### The System to Detect Shabtis
Several consecutive pairs of convolutional and pooling layers are aimed at first extracting simple characteristics, such as lines or vertices, to more complex characteristics, as in our case would be the shape and outstanding attributes of a shabti. It also uses sequences of 1\(x\)1 reduction layers and 3 \(\times\) 3 convolutional layers inspired by the GoogLeNet model (Inception) [44; 45] and the Network in Network (NiN) model to reduce the number of features before costly parallel blocks. Some parameters established in both networks (FN and HN) have been: batch = 64, subdivisions = 16, width = 416, height = 416, channels = 3, momentum = 0.9, decay = 0.0005, angle = 0, saturation = 1.5, exposure = 1.5, hue = 0.1, learning rate = 0.001. YOLOv3 is composed of 75 convolutional layers, 23 shortcut layers after CNN-layers to propagate gradients further and allow efficient training, 4 route layers to merge precedent layers into one layer, 2 up-sample layers used for deconvolution and 3 Yolo layers responsible for calculating the loss at three different scales. A procedure for identifying a shabti using the two networks has been established. The procedure is the following:  
* An input image is introduced in the two YOLO networks. * If the FN model returns some detections (\(FN_{1}\), \(FN_{2}\),..., \(FN_{x}\)), the class with the highest confidence, \(FN_{i}\), is selected after applying non-maxima suppression to suppress weak, overlapping boxes. * If the HN model returns some detections (\(HN_{1}\), \(HN_{2}\),..., \(HN_{y}\)), the class with the highest confidence, \(HN_{j}\), is selected after applying non-maxima suppression to suppress weak, overlapping bounding boxes. * If both models have returned detections, \(FN_{i}\) is selected when \(confidence(FN_{i})>confidence(HN_{j})\), and \(HN_{j}\) otherwise. If the bounding box \(HN_{j}\) is not inside the bounding box \(FN_{i}\), the non-selected class is also shown to the user as another possibility whenever the class is different. * If only the FN model has returned detections, \(FN_{x}\) is selected. * If only the HN model has returned detections, \(HN_{y}\) is selected. * Local data and data retrieved from Europeana are shown for the selected class. In CNNs, the square average error is often used as a loss function. However, YOLOv3 detects the bounding boxes and, hence, the loss function is different. This concept is necessary for our project when detecting more than one shabti at the same time. Since two networks have been used (FN and HN), when both of them detect a shabti, it is necessary to check whether the HN bounding box is inside the FN bounding box or not. If not, these hieroglyphs are not part of the shabti detected by the FN model. Specifically, this function is the following:  
\[ \begin{array}{ll}e&=\ \lambda_{coord}\sum_{i=0}^{S^{2}}\sum_{j=0}^{B} \mathds{1}_{ij}^{obj}(x_{i}-\hat{x_{i}})^{2}+(y_{i}-\hat{y_{i}})^{2}\\ &+\lambda_{coord}\sum_{i=0}^{S^{2}}\sum_{j=0}^{B}\mathds{1}_{ij}^{obj}\big{(} \sqrt{\overline{w_{i}}}-\overline{\overline{w_{i}}}\big{)}^{2}+\bigg{(} \sqrt{\overline{u_{i}}}-\sqrt{\overline{h_{i}}}\bigg{)}^{2}\\ &+\sum_{i=0}^{S^{2}}\sum_{j=0}^{B}\mathds{1}_{ij}^{obj}\big{(}C_{i}-\hat{C_{i} }\big{)}^{2}+\lambda_{noobj}\sum_{i=0}^{S^{2}}\sum_{j=0}^{B}\mathds{1}_{ij}^{ noobj}\big{(}C_{i}-\hat{C_{i}}\big{)}^{2}\\ &+\sum_{i=0}^{S^{2}}\mathds{1}_{i}^{obj}\sum_{c\in classes}\big{(}p_{i}(c)-\hat{ p_{i}}(c)\big{)}^{2}\end{array}  \tag{1}\]  
where the first term evaluates, for each grid \(S\cdot S\) and each bounding box \(B\) detected in each grid, the error of the central position \((x,y)\) of the bounding box of some found object compared with the real value that the bounding box should have. \(\mathds{1}_{ij}^{obj}\) is 1 if an object is present in grid cell \(i\) and the predictor in bounding box \(j\) is responsible for that prediction.