Config Util¶
-
class
ConfigUtil(operation, num_epochs, batch_size, train_data_paths, validation_data_path, test_data_paths, test_originals_path, results_save_path, train_val_split, scale, resize_filter, crop_imgs, crop_size, num_crops, crop_naive, minimum_variation_patch, minimum_variation_batch, augmentations, jpg_noise, jpg_noise_level, dry_run, model_path=None, antialias=True, shuffle_buffer_size=4096, random_seed=None, early_stop_metric='psnr', early_stop_patience=5, save_single=False, grid=False, interpolate=False, with_original=False, combine_halfs=False)[source]¶ - Helper class that encapsulates configuration options, prepares save folders as well as Tensorflow summary writers and initializes logger.Depending on the chosen operation a folder structure will be initialized in the supplied save path.
+- timestamp +-- checkpoints (Tensorflow checkpoints) +-- logs (Tensorflow summary writer logs) +-- models (saved Keras models) +-- pics (saved pictures from different sets) +-- test (saved pictures from test set) +-- train (saved pictures from training set) +-- val (saved pictures from validation set) |-- config_logfile (dump of `ConfigUtil`, `DataPipeline`, `SRModel` configuration) |-- log (log file for debug messages) |-- result_logfile (training and validation metrics will be logged here during training)For evaluation there are multiple options how the upsampled images should be saved. save_single, grid and combine_halfs can be combined and images will be produces for each option. Options interpolate and with_original define how the image grid should look like.- Parameters
operation – One of [“training, “evaluation”].
num_epochs – Number of epochs for training.
batch_size – Number of samples per batch.
train_data_paths – Path to High-Resolution training images.
validation_data_path – Path to High-Resolution validation images.
test_data_paths – Path to Low-Resolution test images.
test_originals_path –
Optional Path to Originals of test images.If your test images were cropped from some image, you can display the cropped patches next to the original whole image in an image grid (see Results Gallery inside documentation for examples).File name of original file needs to match the folder name that contains the crops. See data folder for examples and structure.Only takes effect in evaluation mode, not during training.results_save_path – Path where results are saved.
train_val_split – Ration to split Training data into Training, Validation. Only applicable if no validation_data_path was supplied.
scale – Upsample factor.
resize_filter – Resize Filter for upsampling.
crop_imgs – Whether to crop patches from High-Resolution images, or process complete images.
crop_size –
Tuple specifying dimensions of patches to crop.Channels need to be specified as well, e.g. for 64x64 patches from RGB picture => (64, 64, 3)num_crops – Number of patches to crop from each High-Resolution training image.
crop_naive –
Whether to crop naive (without verifying sufficient diversity in cropped patches).See simple_sr.utils.image.image_transforms.crop_naive for more info.minimum_variation_patch – Minimum variation in cropped patch (only applicable if crop_naive == False).
minimum_variation_batch – Minimum variation across cropped batch (only applicable if crop_naive == False).
augmentations –
Augmentation functions to perform during pre-processing.See simple_sr.utils.image.image_transforms for available augmentation functions.jpg_noise –
Whether corrupt Low-Resolution samples with jpg noise during preprocessing.This is not to be confused with augmenting High-Resolution images with jpg noise, since only Low-Resolution images will be degraded with jpg noise. The idea is that the networks learns to smooth out noise.jpg_noise_level –
Degradation level for jpg noise, in interval [0, 100].100 means max degradation, 0 means no degradation at all.dry_run – Whether to actually create save dirs.
model_path – Path to model for evaluation.
shuffle_buffer_size – Size of tensorflow shuffle buffer in DataPipeline.
random_seed – Random seed for debugging purposes.
early_stop_metric – Metrics SRModel should track to determine whether training should be stopped early.
early_stop_patience – How many epochs may go by without improving early stop metric.
save_single –
Whether to save upsampled images as single filesOnly takes effect in evaluation modegrid – Whether a grid for comparison of models/images should be produced.
interpolate –
Whether saved image grids should include a row for interpolated images.Only takes effect in evaluation mode.with_original –
Whether images grids should include the original image.Only takes effect in evaluation mode.combine_halfs –
Whether images should be stitched together for comparison. See simple_sr.utils.image.image_utils for more info.Only takes effect in evaluation mode.
-
static
training_config(train_data_paths, num_epochs, batch_size, scale, operation='training', validation_data_path=None, test_data_path=None, test_originals_path=None, results_save_path='./', create_save_dirs=True, train_val_split=0.1, crop_imgs=True, crop_size=96, 96, 3, num_crops=16, crop_naive=True, minimum_variation_patch=0.15, minimum_variation_batch=0.05, augmentations=None, jpg_noise=False, jpg_noise_level=50, shuffle_buffer_size=4096, random_seed=None, resize_filter=None, antialias=True, early_stop_metric='psnr', early_stop_patience=5)[source]¶ Convenience method to initialize ConfigUtil in training mode.
- Returns
Initialized ConfigUtil object.
-
static
evaluation_config(data_paths, test_originals_path, model_paths, results_save_path, scale=2, batch_size=8, resize_filter=None, antialias=True, crop_imgs=False, crop_size=128, 128, 3, random_seed=None, num_crops=16, crop_naive=True, minimum_variation_patch=0.15, minimum_variation_batch=0.05, create_save_dirs=True, operation='evaluation', save_single=True, grid=False, interpolate=False, with_original=False, combine_halfs=False)[source]¶ Convenience method to initialize ConfigUtil in evaluation mode.
- Returns
Initialized ConfigUtil object.
-
static
from_yaml(config_yaml_path)[source]¶ - Convenience method to initialize every component needed for training.Components that are initialized are ConfigUtil, DataPipeline and SRModel.To get an idea of the yaml structure and possible options, look into examples/complex_example.yaml.
- Parameters
config_yaml_path – Path to yaml configuration file.
- Returns
Initialized ConfigUtil, DataPipeline and SRModel ready for training.