{"id":19733993,"url":"https://github.com/scaleoutsystems/fedn-imagesegmentation-tutorial","last_synced_at":"2025-12-31T14:38:15.780Z","repository":{"id":104982351,"uuid":"462270952","full_name":"scaleoutsystems/FEDn-ImageSegmentation-tutorial","owner":"scaleoutsystems","description":null,"archived":false,"fork":false,"pushed_at":"2022-04-13T10:20:08.000Z","size":9463,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-28T04:09:10.897Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scaleoutsystems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-22T11:40:06.000Z","updated_at":"2022-03-07T13:02:26.000Z","dependencies_parsed_at":"2023-05-07T11:31:01.555Z","dependency_job_id":null,"html_url":"https://github.com/scaleoutsystems/FEDn-ImageSegmentation-tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/scaleoutsystems/FEDn-ImageSegmentation-tutorial","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scaleoutsystems%2FFEDn-ImageSegmentation-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scaleoutsystems%2FFEDn-ImageSegmentation-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scaleoutsystems%2FFEDn-ImageSegmentation-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scaleoutsystems%2FFEDn-ImageSegmentation-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scaleoutsystems","download_url":"https://codeload.github.com/scaleoutsystems/FEDn-ImageSegmentation-tutorial/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scaleoutsystems%2FFEDn-ImageSegmentation-tutorial/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265820261,"owners_count":23833563,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T00:34:52.801Z","updated_at":"2025-12-31T14:38:15.738Z","avatar_url":"https://github.com/scaleoutsystems.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FEDn-ImageSegmentation-tutorial\n\nThis is an example tutorial for how to set up and train a Image segmentation model in a federated setting using FEDn. \n- Dataset using for this example: Brats2020\n- Model: U-net implemented in keras.\n\n## Pre configuration\n*Requirements: Python with numpy*\n\n- Clone this repo:\n```\ngit clone https://github.com/scaleoutsystems/FEDn-ImageSegmentation-tutorial.git\n```\n- Create a data folder inside of the FEDn-ImageSegmentation-tutorial repo folder:\n```\nmkdir data\n```\n- Insert the dataset: Brats_2020_slices in the data folder.\n- Create data partitions:\n```\npython create_data_partitions.py [NR_OF_CLIENTS] [TRAINING_SUBJECTS_PER_CLIENTS] [VALIDATION_SUBJECTS_PER_CLIENTS]\n```\nConstrains: \\[NR_OF_CLIENTS] **x** **(** \\[TRAINING_SUBJECTS_PER_CLIENTS] **+** \\[VALIDATION_SUBJECTS_PER_CLIENTS] **)** **\u003c=** 369\n\n\n## Setting up pseudo deployment\nIn this tutorial we will build a pseudo distribution i.e. a federation on a single network.\n\n- clone the FEDn repo:\n```\ngit clone -b develop https://github.com/scaleoutsystems/fedn.git\n```\nBUGFIX: \nGo to fedn/config/base-services.yaml and replace line 6 to:\n```\n    image: minio/minio:14128-5ee91dc\n```\n\n\nFor a detailed description visit: https://scaleoutsystems.github.io/fedn/deployment.html\nTo set up the Base, Reducer and Combiner:\n### Base Container\nOpen a new terminal and navigate to the fedn repository folder and type:\n```\ndocker network create fedn_default\ndocker-compose -f config/base-services.yaml up\n```\n### Reducer Container\nOpen a new terminal and navigate to the fedn repository folder.\nCopy the file “config/settings-reducer.yaml.template” to “config/settings-reducer.yaml”.\nStart the container:\n```\ndocker-compose -f config/reducer-dev.yaml -f config/private-network.yaml up \n```\n### Combiner Container\nOpen a new terminal and navigate to the fedn repository folder.\nCopy ‘config/settings.yaml.template’ to ‘config/settings-combiner.yaml’.\nStart the container:\n```\ndocker-compose -f config/combiner-dev.yaml -f config/private-network.yaml up \n```\n### Configurate the Federation\n- Open the Reducer UI: https://localhost:8090\n- Choose keras-helper and Package: package.tar.gz (from the FEDn-ImageSegmentation-tutorial repository).\n- Set the initial model: initial_weights.npz (from the FEDn-ImageSegmentation-tutorial repository)\n- Go to Network and download client config to the FEDn-ImageSegmentation-tutorial repository folder.\n\n### Client Container\nOpen a new terminal and navigate to the FEDn-ImageSegmentation-tutorial repository folder and type:\n\n```\ndocker-compose -f docker-compose.yaml -f private-network.yaml up \n```\n### Federated Training\n- Start the training from the Reducer UI -\u003e Control\n\nHere can you set: \n- Number of rounds, \n- Round timeout - the maximum amount of time the aggregators will wait for a model update,\n- Validate - Choose if you want to run a validation call on each client on every global model.\n### Global Validation\n- To see global model validation go to Reducer UI -\u003e Dashboard\n### Download Global Model\n- Copy the desired global model id from the Dashboard (based on the score).\n- Then go to the minio UI: https://localhost:9001\n- the default login is username: fedn_admin, password: password (but you can change it in the fedn-repo under config/base-services.yaml, line 12-13)\n- go to fedn-models -\u003e Browse and download the model weights with the desired id.\n\nTo use the model for local inference, you could look at the notebook: SOON TO BE ADDED!\n\n# Details\n## Client configuration\nIf you wish to modify the training or the validation settings the relevant script is defined under the clients folder. Simple hypertuning of training and model can be made from the client/settings.yaml file:\n```\n# Parameters for model settings\nbinary_class: False\nimage_dimensions: 256, 256 # For downsampling (128,128)\nNfilter_start: 32\ndepth: 3\n\n# Parameters for local training\nbatch_size: 8\nepochs: 1\n\n```\n- Create a compute package. \n```\ntar -czvf package.tar.gz client\n\n```\nFor any modification regarding the model settings, initiate new seed model weights:\n*Additional requirements: tensorflow 2, FEDn*\n\n```\npython create_seed_weights.py \n```\n## Compute package\nThe compute package is a tarball of the client folder, it consists of all instructions to train, validate and communicate with the Combiner.\nTo read and write the model weights in the train.py and validate.py scripts FEDn is using a helper class (KerasHelper for keras models).\nThe fedn.yaml file is showing the entrypoints for the commands (train and validate in this exampple).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscaleoutsystems%2Ffedn-imagesegmentation-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscaleoutsystems%2Ffedn-imagesegmentation-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscaleoutsystems%2Ffedn-imagesegmentation-tutorial/lists"}