Skip to main content

segmentation_models_trainer

Python application maintainer DOI

Framework to train semantic segmentation models on TensorFlow using json files as input, as follows:

{
    "name": "test",
    "epochs": 4,
    "experiment_data_path": "/data/test",
    "checkpoint_frequency": 10,
    "warmup_epochs": 2,
    "use_multiple_gpus": false,
    "hyperparameters": {
        "batch_size": 16,
        "optimizer": {
            "name": "Adam",
            "config": {
                "learning_rate": 0.0001
            }
        }
    },
    "train_dataset": {
        "name": "train_ds",
        "file_path": "/data/train_ds.csv",
        "n_classes": 1,
        "dataset_size": 1000,
        "augmentation_list": [
            {
                "name": "random_crop",
                "parameters": {
                    "crop_width": 256,
                    "crop_height": 256
                }
            },
            {
                "name": "per_image_standardization",
                "parameters": {}
            }
        ],
        "cache": true,
        "shuffle": true,
        "shuffle_buffer_size": 10000,
        "shuffle_csv": true,
        "ignore_errors": true,
        "num_paralel_reads": 4,
        "img_dtype": "float32",
        "img_format": "png",
        "img_width": 512,
        "img_length": 512,
        "use_ds_width_len": false,
        "autotune": -1,
        "distributed_training": false
    },
    "test_dataset": {
        "name": "test_ds",
        "file_path": "/data/test_ds.csv",
        "n_classes": 1,
        "dataset_size": 200,
        "augmentation_list": [
            {
                "name": "random_crop",
                "parameters": {
                    "crop_width": 256,
                    "crop_height": 256
                }
            },
            {
                "name": "random_flip_left_right",
                "parameters": {}
            },
            {
                "name": "random_flip_up_down",
                "parameters": {}
            },
            {
                "name": "random_brightness",
                "parameters": {
                    "max_delta": 0.1
                }
            },
            {
                "name": "random_contrast",
                "parameters": {
                    "lower": 0.5,
                    "upper": 1.5
                }
            },
            {
                "name": "random_saturation",
                "parameters": {
                    "lower": 0.5,
                    "upper": 1.5
                }
            },
            {
                "name": "random_hue",
                "parameters": {
                    "max_delta": 0.01
                }
            },
            {
                "name": "per_image_standardization",
                "parameters": {}
            }
        ],
        "cache": true,
        "shuffle": true,
        "shuffle_buffer_size": 10000,
        "shuffle_csv": true,
        "ignore_errors": true,
        "num_paralel_reads": 4,
        "img_dtype": "float32",
        "img_format": "png",
        "img_width": 512,
        "img_length": 512,
        "use_ds_width_len": false,
        "autotune": -1,
        "distributed_training": false
    },
    "model": {
        "description": "test case",
        "backbone": "resnet18",
        "architecture": "Unet",
        "activation": "sigmoid",
        "use_imagenet_weights": true
    },
    "loss": {
        "class_name": "bce_dice_loss",
        "config": {},
        "framework": "sm"
    },
    "callbacks": {
        "items": [
            {
                "name": "TensorBoard",
                "config": {
                    "update_freq": "epoch"
                }
            },
            {
                "name": "BackupAndRestore",
                "config": {}
            },
            {
                "name": "ReduceLROnPlateau",
                "config": {
                    "monitor": "val_loss",
                    "factor": 0.2,
                    "patience": 5,
                    "min_lr": 0.00000000001
                }
            },
            {
                "name": "ModelCheckpoint",
                "config": {
                    "monitor": "iou_score",
                    "save_best_only": false,
                    "save_weights_only": false,
                    "verbose":1
                }
            },
            {
                "name": "ImageHistory",
                "config": {
                    "draw_interval": 1,
                    "page_size": 10
                }
            }
        ]
    },
    "metrics": {
        "items": [
            {
                "class_name": "iou_score",
                "config": {},
                "framework": "sm"
            },
            {
                "class_name": "precision",
                "config": {},
                "framework": "sm"
            },
            {
                "class_name": "recall",
                "config": {},
                "framework": "sm"
            },
            {
                "class_name": "f1_score",
                "config": {},
                "framework": "sm"
            },
            {
                "class_name": "f2_score",
                "config": {},
                "framework": "sm"
            },
            {
                "class_name": "MeanIoU",
                "config": {
                    "num_classes": 2
                },
                "framework": "tf.keras"
            }
        ]
    }
}

Training usage:

python train.py --pipeline_config_path=my_experiment.json

Citing:

@software{philipe_borba_2020_4060390,
  author       = {Philipe Borba},
  title        = {phborba/segmentation\_models\_trainer: First Release},
  month        = sep,
  year         = 2020,
  publisher    = {Zenodo},
  version      = {v0.1},
  doi          = {10.5281/zenodo.4060390},
  url          = {https://doi.org/10.5281/zenodo.4060390}
}

Release files for segmentation-models-trainer 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for segmentation-models-trainer 0.2
File Size Uploaded
segmentation_models_trainer-0.2.tar.gz 21.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for segmentation-models-trainer 0.2
File Interpreter ABI Platform
segmentation_models_trainer-0.2-py3-none-any.whl Python 3 none any Details

Total release size: 55.8 kB

Release files / segmentation_models_trainer-0.2.tar.gz

Download URL segmentation_models_trainer-0.2.tar.gz
Size 21.3 kB
Tags Source
SHA-256 checksum
How to use checksums
656aad1f1903cedf4e5168738f06a99cdb721121b025dc638f7a111d72cf086c
BLAKE2b-256 checksum
How to use checksums
d7e640fd17547a55afe02a19f066726fcb6ade050e49bb269cf34f95fa132a5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0

Release files / segmentation_models_trainer-0.2-py3-none-any.whl

Download URL segmentation_models_trainer-0.2-py3-none-any.whl
Size 34.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2cfd4a00fcaa9bb2647085d18e63c569be96f330e4afb8b17ced6d7b09ee6165
BLAKE2b-256 checksum
How to use checksums
b44f4f72089982caedc4cace7e6da971d2d83db8a6b52cf295a9e36694e4eb45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0

Release history Release notifications | RSS feed

This release

0.2 This release

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page