Model initialization
The pylaia-htr-create-model
command can be used to create a PyLaia model. To know more about the options of this command, use pylaia-htr-create-model --help
.
Purpose
The general architecture of PyLaia is composed of convolutional blocks followed by a set a bi-directionnal recurrent layers and a linear layer. PyLaia is fully configurable by the user, including:
-
Number of convolutional blocks,
-
Number of recurrent layers,
-
Batch normalization,
-
Pooling layers,
-
Activation function,
-
…
This command will create a pickled file (named model
by default), which is required to initialize the LaiaCRNN
class before training.
Parameters
The full list of parameters is detailed in this section.
General parameters
Parameter | Description | Type | Default |
---|---|---|---|
|
Positional argument. Path to a file mapping characters to integers. The CTC symbol must be mapped to integer 0. |
|
|
|
Path to a JSON configuration file |
|
|
|
Height of the input images. If set to 0, a variable height model will be used (see |
|
0 |
|
Use custom adaptive pooling layers to enable training with variable height images. Takes into account the size of each individual image within the batch (before padding). Should be in |
|
|
|
Whether to save the model to a file. |
|
|
Common parameters
Name | Description | Type | Default |
---|---|---|---|
|
Directory where the model will be saved |
|
|
|
Filename of the model. |
|
|
Logging arguments
Name | Description | Type | Default |
---|---|---|---|
|
Logging format. |
|
|
|
Logging level. Should be in
|
|
|
|
Filepath for the logs file. Can be a filepath or a filename to be created in |
|
|
|
Whether to overwrite the logfile or to append. |
|
|
|
If filename is set, use this to log also to stderr at the given level. |
|
|
Architecture arguments
Name | Description | Type | Default |
---|---|---|---|
|
Number of channels of the input images. |
|
|
|
Whether the text is written vertically. |
|
|
|
Number of features in each convolutional layer. |
|
|
|
Kernel size of each convolutional layer (e.g. [n,n,…] or [[h1,w1],[h2,w2],…]). |
|
|
|
Stride of each convolutional layer. (e.g. [n,n,…] or [[h1,w1],[h2,w2],…]) |
|
|
|
Spacing between each convolutional layer kernel elements. (e.g. [n,n,…] or [[h1,w1],[h2,w2],…]) |
|
|
|
Type of activation function in each convolutional layer (from |
|
|
|
MaxPooling size after each convolutional layer. (e.g. [n,n,…] or [[h1,w1],[h2,w2],…]). |
|
|
|
Dropout probability at the input of each convolutional layer. |
|
|
|
Whether to do batch normalization before the activation in each convolutional layer. |
|
|
|
Number of recurrent layers. |
|
|
|
Number of units in each recurrent layer. |
|
|
|
Dropout probability at the input of each recurrent layer. |
|
|
|
Type of recurrent layer (from |
|
|
|
Dropout probability at the input of the final linear layer. |
|
|
Examples
The model can be configured using command-line arguments or a YAML configuration file. Note that CLI arguments override the values from the configuration file.
Example with Command Line Arguments (CLI)
Run the following command to create a model:
pylaia-htr-create-model /path/to/syms.txt \
--fixed_input_height 128 \
--crnn.rnn_layers 4 \
--logging.filepath model.log \
--common.train_path my_experiments/
Example with a YAML configuration file
Run the following command to create a model:
pylaia-htr-create-model --config config_create_model.yaml
Where config_create_model.yaml
is:
crnn:
cnn_activation:
- LeakyReLU
- LeakyReLU
- LeakyReLU
- LeakyReLU
cnn_batchnorm:
- true
- true
- true
- true
cnn_dilation:
- 1
- 1
- 1
- 1
cnn_kernel_size:
- 3
- 3
- 3
- 3
cnn_num_features:
- 12
- 24
- 48
- 48
cnn_poolsize:
- 2
- 2
- 0
- 2
lin_dropout: 0.5
rnn_dropout: 0.5
rnn_layers: 3
rnn_type: LSTM
rnn_units: 256
fixed_input_height: 128
save_model: true
syms: /path/to/syms.txt