# Synthetized Multilanguage OCR Using CRNN and SVTR Models for Realtime Collaborative Tools
## 4 Materials and Methods
### CRNN Model Type  
For image-based text recognition, CRNN [31; 32; 33; 34; 35] is an increasingly popular modeling technique [26]. The convolutional layers extract characteristics from the input sequence, whereas the recurrent layers capture temporal dependencies [26; 29]. The output of the last convolutional layer is fed into a recurrent layer, either Long Short-Term Memory (LSTM) or Gated Recurrent Unit (GRU) layer. The input to the network is composed of the following sequence of 'input vectors' \(x_{1},x_{2},\ldots,x_{T}\), where \(T\) is considered the 'length of the sequence'. The output of this network is composed of the following 'output vector' \(y_{1},y_{2},\ldots,y_{T}\). The output of the \(i^{th}\) the 'convolutional layer' can be defined as:  
\[h_{i}=f(W_{i}*x+b_{i}),\]  
where \(W_{i}\) is considered as the 'weight matrix' for the \(i\)th 'convolutional layer', where \(b_{i}\) is considered as the 'bias vector' for \(i\)th convolutional layer, \(*\) shows the 'convolution op', and \(f\) is an 'activation function'. The output of the recurrent layer is shown as \(h_{t}=g(h_{t-1},x_{t})\), where \(h_{t}\) is considered as the 'hidden state' of the recurrent layer at time \(t\), \(g\) is the'recurrent function,' and \(h_{t-1}\) is the 'hidden state' of the recurrent layer defined at time \(t-1\).  
Figure 2: Modern text recognizers using (a) CRNN and (b) SVTR models, adapted from [30].  
The LSTM is a recurrent layer used in the CRNN algorithm to capture temporal dependencies in the input sequence. For an LSTM layer, the recurrent function \(g\) can be expressed as follows:  
\(i_{t}=\sigma(W_{t}x_{t}+U_{l}h_{t-1}+b_{l})\)  
\(f_{t}=\sigma(W_{f}x_{t}+U_{f}h_{t-1}+b_{f})\)  
\(o_{t}=\sigma(W_{o}x_{t}+U_{o}h_{t-1}+b_{o})\)  
\(c_{t}=f_{t}\odot c_{t-1}+i\odot\tanh(W_{c}x_{t}+U_{c}h_{t-1}+b_{c})\)  
\(h_{t}=o_{t}\odot\tanh(c_{t})\)  
where \(i_{t}\), \(f_{t}\), \(o_{t}\), and \(c_{t}\) are the 'InputGate', 'ForgetGate', 'OutputGate', and 'CellState' vectors at time \(t\), and \(W_{i}\), \(W_{f}\), \(W_{o}\), \(W_{c}\), \(U_{l}\), \(U_{f}\), \(U_{o}\), \(U_{c}\), \(b_{l}\), \(b_{f}\), \(b_{o}\), and \(b_{c}\) are the 'weight matrices' and 'bias vectors' for LSTM [36; 37; 38].  
GRU is a recurrent layer used in the CRNN to capture temporal dependencies in the input sequence. For a GRU layer, the recurrent function \(g\) can be expressed as:  
\(r_{t}=\sigma(W_{r}x_{t}+U_{r}h_{t-1}+b_{r})\)  
\(z_{t}=\sigma(W_{2}x_{t}+U_{2}h_{t-1}+b_{z})\)  
\(\tilde{h}_{t}=\tanh(W_{h}x_{t}+U_{h}(r_{t}\odot h_{t-1})+b_{h})\)  
\(h_{t}=(1-z_{t})\odot h_{t-1}+z_{t}\odot\tilde{h}_{t}\)  
where \(r_{t}\), \(z_{t}\), and \(\tilde{h}_{t}\) are the 'ResetGate', 'UpdateGate', and 'CandidateHiddenState' vectors at time \(t\), while \(W_{r}\), \(W_{z}\), \(W_{h}\), \(U_{r}\), \(U_{z}\), \(U_{h}\), \(b_{r}\), \(b_{z}\), and \(b_{h}\) are the 'weight matrices' and 'bias vectors' for the GRU.  
As shown in the CRNN architecture in Figure 3, the extraction process of beneficial features is performed sequentially, applying convolutions and max-pooling operations. When these are received, they are put into the recurrent unit, which stores information based on how it happened in time.  
Figure 3: CRNN architecture [33] with CRNN feature extraction, adapted from [35].