Skip to content

Commit

Permalink
Merge pull request #275 from VectorInstitute/dbe/updating_flamby_install
Browse files Browse the repository at this point in the history
Updating the FLamby installation instructions to reflect some changes on their end.
  • Loading branch information
emersodb authored Nov 11, 2024
2 parents d24d905 + a33b335 commit c2c3035
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 221 deletions.
68 changes: 50 additions & 18 deletions research/flamby/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
### Installing the Flamby dependencies from Fixed Requirements File

__NOTE__: The standard workflow discussed by FLamby is in the next section, but is currently broken due to dependency changes.

Create a python environment with your preferred env manager. We'll use conda below
``` bash
conda create -n flamby_fl4health python=3.10
conda activate flamby_fl4health
```
Install the dependencies of both FLamby and FL4Health using the fixed requirements file at `research/flamby/flamby_requirements.txt`.
```bash
cd <fl4health_repository>
pip install --src <path/to/clone/flamby/repository/to> -r research/flamby/flamby_requirements.txt
```
Note that this installation will clone the FLamby repo to the path provided to --src and then install FLamby as a package.

### Installing the Flamby dependencies (Old Workflow)
### Installing the Flamby dependencies

__NOTE__: The workflow below is normally the smoothest way to construct the FLamby + FL4Health environment required to run the FLamby experiments. However, with a recent upgrade to MonAI, some of the functionality that FLamby depends on are broken. Until this is fixed, the workflow below will not work.

Expand All @@ -33,8 +17,56 @@ cd <fl4health_repository>
pip install --upgrade pip poetry
poetry install --with "dev, dev-local, test, codestyle"
cd <FLamby_repository>
pip install -e ".[all_extra]"
pip install -e ".[cam16, heart, isic2019, ixi, lidc, tcga]"
```
__NOTE__: We avoid installing Fed-KITS2019, as it requires a fairly old version on nnUnet, which we no longer support in our library.

In addition, you'll have to edit the code for `FedIXITiny` in `flamby/datasets/fed_ixi/datasets.py` replacing the following

<table>
<tr>
<th>Old</th>
<th>New</th>
</tr>
<tr>
<td>

``` python
from monai.transforms import (
AddChannel,
...
```
</td>
<td>

``` python
from monai.transforms import (
EnsureChannelFirst,
...
```
</td>
</tr>
</tr>
<tr>
<td>

```python
default_transform = Compose(
[ToTensor(), AddChannel(), Resize(self.common_shape)]
```
</td>
<td>

```python
default_transform = Compose(
[ToTensor(), EnsureChannelFirst(channel_dim="no_channel"), Resize(self.common_shape)]
)
```
</td>
</tr>
</table>

This is because AddChannel was removed in Version 1.3 of MonAI

### Downloading the Fed ISIC 2019 Dataset

Expand Down
202 changes: 0 additions & 202 deletions research/flamby/flamby_requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion research/flamby/single_node_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def validate(self, val_metric_mngr: MetricManager) -> None:
for input, target in self.val_loader:
input, target = input.to(self.device), target.to(self.device)

preds = self.model(input)
preds = {"predictions": self.model(input)}
batch_loss = self.criterion(preds["predictions"], target)
running_loss += batch_loss.item()
val_metric_mngr.update(preds, target)
Expand Down

0 comments on commit c2c3035

Please sign in to comment.