@ -48,7 +48,7 @@ If you have an image label with height and width of 10, for a binary case the fi
A small sample of training data for binarization experiment can be found here, [Training data sample](https://qurator-data.de/~vahid.rezanezhad/binarization_training_data_sample/), which contains images and lables folders.
### Training , evaluation and output
The train and evaluation folders should contain subfolders of images and labels.
The train and evaluation folders should contain subfolders of images and labels.
The output folder should be an empty folder where the output model will be written to.
### Parameter configuration
@ -63,7 +63,7 @@ The output folder should be an empty folder where the output model will be writt
* flip_aug: If ``true``, different types of filp will be applied on image. Type of flips is given with "flip_index" in train.py file.
* blur_aug: If ``true``, different types of blurring will be applied on image. Type of blurrings is given with "blur_k" in train.py file.
* scaling: If ``true``, scaling will be applied on image. Scale of scaling is given with "scales" in train.py file.
* rotation_not_90: If ``true``, rotation (not 90 degree) will be applied on image. Rothation angles are given with "thetha" in train.py file.
* rotation_not_90: If ``true``, rotation (not 90 degree) will be applied on image. Rotation angles are given with "thetha" in train.py file.
* rotation: If ``true``, 90 degree rotation will be applied on image.
* binarization: If ``true``,Otsu thresholding will be applied to augment the input data with binarized images.
* scaling_bluring: If ``true``, combination of scaling and blurring will be applied on image.
@ -73,5 +73,3 @@ The output folder should be an empty folder where the output model will be writt
* weighted_loss: If ``true``, this means that you want to apply weighted categorical_crossentropy as loss fucntion. Be carefull if you set to ``true``the parameter "is_loss_soft_dice" should be ``false``
* data_is_provided: If you have already provided the input data you can set this to ``true``. Be sure that the train and eval data are in "dir_output". Since when once we provide training data we resize and augment them and then we write them in sub-directories train and eval in "dir_output".
* dir_train: This is the directory of "images" and "labels" (dir_train should include two subdirectories with names of images and labels ) for raw images and labels. Namely they are not prepared (not resized and not augmented) yet for training the model. When we run this tool these raw data will be transformed to suitable size needed for the model and they will be written in "dir_output" in train and eval directories. Each of train and eval include "images" and "labels" sub-directories.
assertos.path.isdir(labels_input),"{} is not a directory".format(labels_input)
returnimage_input,labels_input
ex=Experiment()
@ex.config
defconfig_params():
n_classes=None# Number of classes. In the case of binary classification this should be 2.
n_epochs=1# Number of epochs.
input_height=224*1# Height of model's input in pixels.
input_width=224*1# Width of model's input in pixels.
weight_decay=1e-6# Weight decay of l2 regularization of model layers.
n_batch=1# Number of batches at each iteration.
learning_rate=1e-4# Set the learning rate.
patches=False# Divides input image into smaller patches (input size of the model) when set to true. For the model to see the full image, like page extraction, set this to false.
augmentation=False# To apply any kind of augmentation, this parameter must be set to true.
flip_aug=False# If true, different types of flipping will be applied to the image. Types of flips are defined with "flip_index" in train.py.
blur_aug=False# If true, different types of blurring will be applied to the image. Types of blur are defined with "blur_k" in train.py.
scaling=False# If true, scaling will be applied to the image. The amount of scaling is defined with "scales" in train.py.
binarization=False# If true, Otsu thresholding will be applied to augment the input with binarized images.
dir_train=None# Directory of training dataset with subdirectories having the names "images" and "labels".
dir_eval=None# Directory of validation dataset with subdirectories having the names "images" and "labels".
dir_output=None# Directory where the output model will be saved.
pretraining=False# Set to true to load pretrained weights of ResNet50 encoder.
scaling_bluring=False# If true, a combination of scaling and blurring will be applied to the image.
scaling_binarization=False# If true, a combination of scaling and binarization will be applied to the image.
scaling_flip=False# If true, a combination of scaling and flipping will be applied to the image.
thetha=[10,-10]# Rotate image by these angles for augmentation.
blur_k=['blur','gauss','median']# Blur image for augmentation.
scales=[0.5,2]# Scale patches for augmentation.
flip_index=[0,1,-1]# Flip image for augmentation.
continue_training=False# Set to true if you would like to continue training an already trained a model.
index_start=0# Index of model to continue training from. E.g. if you trained for 3 epochs and last index is 2, to continue from model_1.h5, set "index_start" to 3 to start naming model with index 3.
dir_of_start_model=''# Directory containing pretrained encoder to continue training the model.
is_loss_soft_dice=False# Use soft dice as loss function. When set to true, "weighted_loss" must be false.
weighted_loss=False# Use weighted categorical cross entropy as loss fucntion. When set to true, "is_loss_soft_dice" must be false.
data_is_provided=False# Only set this to true when you have already provided the input data and the train and eval data are in "dir_output".
n_classes=None# Number of classes. In the case of binary classification this should be 2.
n_epochs=1# Number of epochs.
input_height=224*1# Height of model's input in pixels.
input_width=224*1# Width of model's input in pixels.
weight_decay=1e-6# Weight decay of l2 regularization of model layers.
n_batch=1# Number of batches at each iteration.
learning_rate=1e-4# Set the learning rate.
patches=False# Divides input image into smaller patches (input size of the model) when set to true. For the model to see the full image, like page extraction, set this to false.
augmentation=False# To apply any kind of augmentation, this parameter must be set to true.
flip_aug=False# If true, different types of flipping will be applied to the image. Types of flips are defined with "flip_index" in train.py.
blur_aug=False# If true, different types of blurring will be applied to the image. Types of blur are defined with "blur_k" in train.py.
scaling=False# If true, scaling will be applied to the image. The amount of scaling is defined with "scales" in train.py.
binarization=False# If true, Otsu thresholding will be applied to augment the input with binarized images.
dir_train=None# Directory of training dataset with subdirectories having the names "images" and "labels".
dir_eval=None# Directory of validation dataset with subdirectories having the names "images" and "labels".
dir_output=None# Directory where the output model will be saved.
pretraining=False# Set to true to load pretrained weights of ResNet50 encoder.
scaling_bluring=False# If true, a combination of scaling and blurring will be applied to the image.
scaling_binarization=False# If true, a combination of scaling and binarization will be applied to the image.
scaling_flip=False# If true, a combination of scaling and flipping will be applied to the image.
thetha=[10,-10]# Rotate image by these angles for augmentation.
blur_k=['blur','gauss','median']# Blur image for augmentation.
scales=[0.5,2]# Scale patches for augmentation.
flip_index=[0,1,-1]# Flip image for augmentation.
continue_training=False# Set to true if you would like to continue training an already trained a model.
index_start=0# Index of model to continue training from. E.g. if you trained for 3 epochs and last index is 2, to continue from model_1.h5, set "index_start" to 3 to start naming model with index 3.
dir_of_start_model=''# Directory containing pretrained encoder to continue training the model.
is_loss_soft_dice=False# Use soft dice as loss function. When set to true, "weighted_loss" must be false.
weighted_loss=False# Use weighted categorical cross entropy as loss fucntion. When set to true, "is_loss_soft_dice" must be false.
data_is_provided=False# Only set this to true when you have already provided the input data and the train and eval data are in "dir_output".