-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs/SK-901 | MonAI README #644
Changes from 16 commits
121cc09
b16692a
aa8d4ce
2ecf1e5
718a37d
18101ec
367a7d8
7607b67
73659c0
d9872d2
23c5f2a
5f324b4
79b91dc
42de958
b775342
33004d5
8939b8e
980e924
f97ac53
df97917
30dc217
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
Implementing 2D Classification Model with MedNIST Dataset Using FEDn | ||
-------------------------------------------------------------------- | ||
|
||
This example provides a step-by-step guide to deploying and running a 2D classification model using the MedNIST dataset in a federated environment with the `FEDn framework <https://www.scaleoutsystems.com/framework>`__ developed by `Scaleout Systems <https://www.scaleoutsystems.com/>`__ . This example builds on the centralized `example <https://github.com/Project-MONAI/tutorials/blob/main/2d_classification/mednist_tutorial.ipynb>`__ from the MonAI project and adapts it for federated learning settings, utilizing the same code for ease of transition. | ||
|
||
The FEDn framework supports researchers with its robust `open-source SDK <https://fedn.readthedocs.io/en/stable/quickstart.html>`__ and a `public SaaS platform <https://fedn.readthedocs.io/en/stable/studio.html>`__ , enabling scalable and efficient federated learning use cases. | ||
|
||
Getting Started | ||
--------------- | ||
|
||
For a step-by-step example guide, click `here <https://github.com/scaleoutsystems/fedn/tree/master/examples/monai-2D-mednist>`__ . | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ | |
dir_path = os.path.dirname(os.path.realpath(__file__)) | ||
sys.path.append(os.path.abspath(dir_path)) | ||
|
||
|
||
train_transforms = Compose( | ||
[ | ||
LoadImage(image_only=True), | ||
|
@@ -54,18 +53,16 @@ def train(in_model_path, out_model_path, data_path=None, client_settings_path=No | |
if client_settings_path is None: | ||
client_settings_path = os.environ.get("FEDN_CLIENT_SETTINGS_PATH", dir_path + "/client_settings.yaml") | ||
|
||
print("client_settings_path: ", client_settings_path) | ||
with open(client_settings_path, "r") as fh: # Used by CJG for local training | ||
try: | ||
client_settings = dict(yaml.safe_load(fh)) | ||
except yaml.YAMLError: | ||
raise | ||
|
||
print("client settings: ", client_settings) | ||
batch_size = client_settings["batch_size"] | ||
max_epochs = client_settings["local_epochs"] | ||
num_workers = client_settings["num_workers"] | ||
split_index = client_settings["split_index"] | ||
split_index = os.environ.get("FEDN_DATA_SPLIT_INDEX") #client_settings["split_index"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
lr = client_settings["lr"] | ||
|
||
if data_path is None: | ||
|
@@ -76,8 +73,7 @@ def train(in_model_path, out_model_path, data_path=None, client_settings_path=No | |
|
||
image_list = clients["client " + str(split_index)]["train"] | ||
|
||
train_ds = MedNISTDataset(data_path="data/MedNIST", transforms=train_transforms, image_files=image_list) | ||
|
||
train_ds = MedNISTDataset(data_path=data_path+"/MedNIST/", transforms=train_transforms, image_files=image_list) | ||
train_loader = DataLoader(train_ds, batch_size=batch_size, shuffle=True, num_workers=num_workers) | ||
|
||
# Load parmeters and initialize model | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ def validate(in_model_path, out_json_path, data_path=None, client_settings_path= | |
|
||
num_workers = client_settings["num_workers"] | ||
batch_size = client_settings["batch_size"] | ||
split_index = client_settings["split_index"] | ||
split_index = os.environ.get("FEDN_DATA_SPLIT_INDEX") # client_settings["split_index"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. |
||
|
||
if data_path is None: | ||
data_path = os.environ.get("FEDN_DATA_PATH") | ||
|
@@ -55,7 +55,7 @@ def validate(in_model_path, out_json_path, data_path=None, client_settings_path= | |
|
||
image_list = clients["client " + str(split_index)]["validation"] | ||
|
||
val_ds = MedNISTDataset(data_path="data/MedNIST", transforms=val_transforms, image_files=image_list) | ||
val_ds = MedNISTDataset(data_path=data_path+"/MedNIST/", transforms=val_transforms, image_files=image_list) | ||
|
||
val_loader = DataLoader(val_ds, batch_size=batch_size, shuffle=True, num_workers=num_workers) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
lr: 0.01 | ||
batch_size: 32 | ||
local_epochs: 10 | ||
batch_size: 8 | ||
local_epochs: 1 | ||
num_workers: 1 | ||
sample_size: 30 | ||
split_index: 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are there 1 .md and 2 .rst files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove .rst from the branch as in MonAI tutorials repo, they have all .md files.