## 3 Improving the East Model
### Loss Function  
The loss function has two parts [18]: the score map loss function, \(L_{s}\), and the geometries' loss function, \(L_{g}\). The formula is as follows:  
\[L=L_{s}+\lambda_{g}L_{g} \tag{1}\]  
where \(\lambda_{g}\) represents the importance between two losses, which is set to 1 by the EAST model. The geometric loss function consists of two parts: the AABB loss function, \(L_{AABB}\), and the angle loss function, \(L_{\theta}\). The AABB loss function is as follows:  
\[L_{AABB}=-\log IoU(\hat{R},R^{*})=-\log\frac{\left|\hat{R}\cap R^{*}\right|}{ \left|\hat{R}\cup R^{*}\right|} \tag{2}\]  
where \(\hat{R}\) represents the predicted AABB geometry and \(R^{*}\) represents the true geometry. The loss function of the rotation angle is calculated as follows:  
\[L_{\theta}(\hat{\theta},\theta^{*})=1-\cos(\hat{\theta}-\theta^{*}) \tag{3}\]  
where \(\hat{\theta}\) represents the predicted rotation angle and \(\theta^{*}\) represents the true rotation angle. The total geometric loss function is calculated as follows:  
\[L_{g}=L_{AABB}+\lambda_{\theta}L_{\theta} \tag{4}\]  
where \(\lambda_{\theta}\) is the balance factor, which is set to 10 according to the literature [18]. One of the problems in text region detection is the imbalance in the number of positive and negative samples and the number of hard and easy samples. In the images of the ICDAR2015 dataset, the text region area accounts for less than 5% of the image area. A large amount of background and few regions containing text create an imbalance of positive and negative samples. As shown in Figure 7, the predicted bounding boxes can be divided into positive and negative samples usually. Boxes with an intersection-over-union (IoU) ratio between predicted and true boxes greater than the threshold (usually set to 0.5) are considered positive samples, and boxes with an IoU less than the threshold are considered negative samples. Most of the predicted bounding boxes are not found where the real boxes overlap with the background. These are considered simple samples, which can then be classified as simple positive samples and simple negative samples. As the number of simple negative samples constitutes the largest proportion of all samples, the loss function is dominated by simple negative samples, and simple positive samples have a limited effect on parameter convergence. Thus, to improve the model's effect, we had to make the model focus more on hard positive samples. Therefore, in this paper, we propose using Focal loss, which was introduced by [PERSON] et al. [30], instead of the original loss function. The cross-entropy loss function for ordinary binary classification is calculated as follows:  
\[CE(p,y)=\left\{\begin{array}[]  
resulting in the model being influenced by a large number of negative samples with poor results. To balance the positive and negative samples, the balanced cross-entropy loss function used by [PERSON] et al. (2019) introduces a balancing factor, \(\alpha_{t}\), and \(\alpha_{t}\) is calculated as in Equation (8), where \(\alpha\in[0,\,1]\). The balanced cross-entropy is calculated as shown in Equation (9). The EAST model uses the balanced cross-entropy loss function. The specific calculation formula is shown in Equation (10) ([PERSON] et al., 2019):  
\[\alpha_{t}=\left\{ \begin{array}{cc}\alpha&y=1\\ 1-\alpha&otherwise\end{array} \right. \tag{8}\]  
\[CE(p_{t})=-\alpha_{t}\log(p_{t}) \tag{9}\]  
\[L_{s}=balanced-xent(\hat{Y},Y^{*}) \tag{10}\]  
where \(\hat{Y}=F_{s}\) represents the predicted score map, and \(Y^{*}\) represents the true value. \(\beta\) is the balancing factor between positive and negative samples, and the formula is calculated as follows:  
\[\beta=1-\frac{\sum_{y^{*}\in Y^{*}}y^{*}}{|Y^{*}|} \tag{11}\]  
Although the balanced cross-entropy loss function improves the imbalance between positive and negative samples, it still does not solve the imbalance between hard and easy samples.