Skip to content
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

813 ah net #815

Merged
merged 55 commits into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
2af8f2c
Add groups parameter into Convolution class
yiheng-wang-nv Jul 20, 2020
f811cbe
Move the project variable to a parameter
yiheng-wang-nv Jul 20, 2020
9d8f542
Merge pull request #1 from Project-MONAI/master
yiheng-wang-nv Jul 21, 2020
46db9f9
Merge branch 'master' of github.com:yiheng-wang-nv/MONAI
yiheng-wang-nv Jul 21, 2020
4f41da4
Add a Relu layer in SEBlock
yiheng-wang-nv Jul 21, 2020
1868a2e
Implementations of SENet
yiheng-wang-nv Jul 21, 2020
9773ae3
Import missed Classes
yiheng-wang-nv Jul 21, 2020
ed94bad
Code reformat via Black
yiheng-wang-nv Jul 21, 2020
f320c18
Merge remote-tracking branch 'upstream/master'
yiheng-wang-nv Jul 22, 2020
f4fa7b4
Parameterization for final act function in SEBlock
yiheng-wang-nv Jul 22, 2020
5c29112
Import missed package
yiheng-wang-nv Jul 22, 2020
00a3a9a
Fix format errors
yiheng-wang-nv Jul 22, 2020
80e01b5
Merge remote-tracking branch 'upstream/master' into 91-senet
yiheng-wang-nv Jul 23, 2020
8c321fe
Merge remote-tracking branch 'upstream/master'
yiheng-wang-nv Jul 23, 2020
1561738
Merge branch '91-senet'
yiheng-wang-nv Jul 23, 2020
bc7a7e4
Merge remote-tracking branch 'upstream/master'
yiheng-wang-nv Jul 24, 2020
b380d35
Modify Relu's default parameter
yiheng-wang-nv Jul 24, 2020
896ae0f
Add parameter to control Dropout layer
yiheng-wang-nv Jul 24, 2020
3e67fad
Add FCN and its unittest code
yiheng-wang-nv Jul 24, 2020
04fe74f
Move FCN from nets into blocks
yiheng-wang-nv Jul 24, 2020
0619bec
Modified due to an exrea package is imported
yiheng-wang-nv Jul 24, 2020
b89a0a8
Remove confused output type
yiheng-wang-nv Jul 24, 2020
b81b447
Specify torchvision version
yiheng-wang-nv Jul 24, 2020
387ca64
Fix torchvision version issue
yiheng-wang-nv Jul 24, 2020
9a0e44c
Use Optional import for torchvision model
yiheng-wang-nv Jul 24, 2020
f352884
Merge remote-tracking branch 'upstream/master' into 813-AHNet
yiheng-wang-nv Jul 24, 2020
5e3dfe2
Reformat
yiheng-wang-nv Jul 24, 2020
73fb639
Merge remote-tracking branch 'upstream/master' into 813-AHNet
yiheng-wang-nv Jul 27, 2020
c346b5a
Merge branch 'master' into 813-AHNet
Nic-Ma Jul 29, 2020
512bcc9
Merge remote-tracking branch 'upstream/master' into 813-AHNet
yiheng-wang-nv Jul 30, 2020
427ef44
Add AHNet implementations
yiheng-wang-nv Jul 31, 2020
8a41dfb
Merge branch 'master' into 813-AHNet
yiheng-wang-nv Jul 31, 2020
74396a9
Reset commit
yiheng-wang-nv Jul 31, 2020
b061aaa
Merge remote-tracking branch 'upstream/master' into 813-AHNet
yiheng-wang-nv Jul 31, 2020
5f7b727
Merge branch '813-AHNet' of github.com:yiheng-wang-nv/MONAI into 813-…
yiheng-wang-nv Jul 31, 2020
0f644aa
Import torchvision
yiheng-wang-nv Jul 31, 2020
3dcdae2
Optional import torchvision 0.5.0
yiheng-wang-nv Jul 31, 2020
890d47a
Add init parameters into MCFCN
yiheng-wang-nv Jul 31, 2020
e74a950
Merge remote-tracking branch 'upstream/master' into 813-AHNet
yiheng-wang-nv Aug 3, 2020
9885ef5
Merge branch 'master' into 813-AHNet
Nic-Ma Aug 3, 2020
7af9f0d
Install torchvision to avoid conflicts
yiheng-wang-nv Aug 3, 2020
fa20541
Merge branch '813-AHNet' of github.com:yiheng-wang-nv/MONAI into 813-…
yiheng-wang-nv Aug 3, 2020
b75dabd
Fix torchvision install typo
yiheng-wang-nv Aug 3, 2020
97465b7
Merge remote-tracking branch 'upstream/master' into 813-AHNet
yiheng-wang-nv Aug 4, 2020
6d6dbe0
Merge branch 'master' into 813-AHNet
Nic-Ma Aug 4, 2020
ecb30da
Modifications according to Code Review
yiheng-wang-nv Aug 4, 2020
6892f48
Merge branch '813-AHNet' of github.com:yiheng-wang-nv/MONAI into 813-…
yiheng-wang-nv Aug 4, 2020
3349662
Change torchvision import method
yiheng-wang-nv Aug 4, 2020
7049baa
Remove unused exact_version
yiheng-wang-nv Aug 4, 2020
ab456fa
Add placeholder for f-string in error raise parts
yiheng-wang-nv Aug 4, 2020
45f0b26
Autofix format errors
yiheng-wang-nv Aug 4, 2020
6ea4e08
Merge branch 'master' into 813-AHNet
wyli Aug 4, 2020
d2862ab
[MONAI] python code formatting
monai-bot Aug 4, 2020
2f69c58
Merge remote-tracking branch 'upstream/master' into 813-AHNet
yiheng-wang-nv Aug 4, 2020
affdfa4
Merge branch '813-AHNet' of github.com:yiheng-wang-nv/MONAI into 813-…
yiheng-wang-nv Aug 4, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ jobs:
python -m pip install --upgrade pip wheel
python -m pip uninstall -y torch torchvision
if [ ${{ matrix.pytorch-version }} == "latest" ]; then
python -m pip install torch
python -m pip install torch torchvision
else
python -m pip install torch==${{ matrix.pytorch-version }}
python -m pip install torchvision==0.5.0
fi
python -m pip install -r requirements-dev.txt
python -m pip list
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,13 @@ jobs:
name: Install torch cpu from pytorch.org (Windows only)
run: |
python -m pip install torch==1.4 -f https://download.pytorch.org/whl/cpu/torch_stable.html
python -m pip install torchvision==0.5.0
# min. requirements for windows instances
python -c "f=open('requirements-dev.txt', 'r'); txt=f.readlines(); f.close(); print(txt); f=open('requirements-dev.txt', 'w'); f.writelines(txt[1:11]); f.close()"
- name: Install the dependencies
run: |
python -m pip install torch==1.4
python -m pip install torchvision==0.5.0
cat "requirements-dev.txt"
python -m pip install -r requirements-dev.txt
python -m pip list
Expand Down Expand Up @@ -119,7 +121,7 @@ jobs:
which python
python -m pip install --upgrade pip wheel
python -m pip uninstall -y torch torchvision
python -m pip install torch==1.4
python -m pip install torch==1.4 torchvision==0.5.0
python -m pip install -r requirements-dev.txt
- name: Run quick tests (GPU)
run: |
Expand Down Expand Up @@ -162,7 +164,7 @@ jobs:
# install the latest pytorch for testing
# however, "pip install monai*.tar.gz" will build cpp/cuda with an isolated
# fresh torch installation according to pyproject.toml
python -m pip install torch>=1.4
python -m pip install torch>=1.4 torchvision
yiheng-wang-nv marked this conversation as resolved.
Show resolved Hide resolved
- name: Test source archive and wheel file
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/setupapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
which python
python -m pip install --upgrade pip wheel
python -m pip uninstall -y torch torchvision
python -m pip install torch==1.4
python -m pip install torch==1.4 torchvision==0.5.0
python -m pip install -r requirements-dev.txt
- name: Run unit tests report coverage
run: |
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
- name: Install the dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install torch==1.4
python -m pip install torch==1.4 torchvision==0.5.0
python -m pip install -r requirements-dev.txt
- name: Run quick tests CPU ubuntu
run: |
Expand Down Expand Up @@ -124,10 +124,11 @@ jobs:
name: Install torch cpu from pytorch.org (Windows only)
run: |
python -m pip install torch==1.4 -f https://download.pytorch.org/whl/cpu/torch_stable.html
python -m pip install torchvision==0.5.0
- name: Install the dependencies
run: |
# min. requirements for windows instances
python -m pip install torch==1.4
python -m pip install torch==1.4 torchvision==0.5.0
python -c "f=open('requirements-dev.txt', 'r'); txt=f.readlines(); f.close(); print(txt); f=open('requirements-dev.txt', 'w'); f.writelines(txt[1:5]); f.close()"
cat "requirements-dev.txt"
python -m pip install -r requirements-dev.txt
Expand Down
25 changes: 25 additions & 0 deletions docs/source/networks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@ Blocks
.. autoclass:: ResidualUnit
:members:

`GCN Module`
~~~~~~~~~~~~
.. autoclass:: GCN
:members:

`Refinement Module`
~~~~~~~~~~~~~~~~~~~
.. autoclass:: Refine
:members:

`FCN Module`
~~~~~~~~~~~~
.. autoclass:: FCN
:members:

`Multi-Channel FCN Module`
~~~~~~~~~~~~~~~~~~~~~~~~~~
.. autoclass:: MCFCN
:members:

`Squeeze-and-Excitation`
~~~~~~~~~~~~~~~~~~~~~~~~
.. autoclass:: ChannelSELayer
Expand Down Expand Up @@ -144,6 +164,11 @@ Nets
----
.. currentmodule:: monai.networks.nets

`Ahnet`
~~~~~~~
.. autoclass:: AHNet
:members:

`Densenet3D`
~~~~~~~~~~~~
.. autoclass:: DenseNet
Expand Down
9 changes: 5 additions & 4 deletions examples/distributed_training/unet_evaluation_horovod.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,22 @@

"""

import argparse
import os
from glob import glob

import horovod.torch as hvd
import nibabel as nib
import numpy as np
import torch
import torch.multiprocessing as mp
import argparse
from torch.utils.data.distributed import DistributedSampler
import horovod.torch as hvd

import monai
from monai.data import create_test_image_3d, Dataset, DataLoader
from monai.data import DataLoader, Dataset, create_test_image_3d
from monai.inferers import sliding_window_inference
from monai.metrics import DiceMetric
from monai.transforms import Compose, LoadNiftid, AsChannelFirstd, ScaleIntensityd, ToTensord
from monai.transforms import AsChannelFirstd, Compose, LoadNiftid, ScaleIntensityd, ToTensord


def evaluate(args):
Expand Down
11 changes: 6 additions & 5 deletions examples/distributed_training/unet_training_horovod.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,29 @@

"""

import argparse
import os
import sys
from glob import glob

import horovod.torch as hvd
import nibabel as nib
import numpy as np
import torch
import torch.multiprocessing as mp
import argparse
from torch.utils.data.distributed import DistributedSampler
import horovod.torch as hvd

import monai
from monai.data import DataLoader, Dataset, create_test_image_3d
from monai.transforms import (
AsChannelFirstd,
Compose,
LoadNiftid,
AsChannelFirstd,
ScaleIntensityd,
RandCropByPosNegLabeld,
RandRotate90d,
ScaleIntensityd,
ToTensord,
)
from monai.data import create_test_image_3d, Dataset, DataLoader


def train(args):
Expand Down
5 changes: 2 additions & 3 deletions monai/losses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
Dice,
DiceLoss,
GeneralizedDiceLoss,
GeneralizedWassersteinDiceLoss,
MaskedDiceLoss,
dice,
generalized_dice,
MaskedDiceLoss,
GeneralizedWassersteinDiceLoss,
)

from .focal_loss import FocalLoss
from .tversky import TverskyLoss
2 changes: 1 addition & 1 deletion monai/losses/tversky.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# limitations under the License.

import warnings
from typing import Union, Optional, Callable
from typing import Callable, Optional, Union

import torch
from torch.nn.modules.loss import _Loss
Expand Down
2 changes: 1 addition & 1 deletion monai/metrics/meandice.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# limitations under the License.

import warnings
from typing import Optional, Union, Callable
from typing import Callable, Optional, Union

import torch

Expand Down
2 changes: 1 addition & 1 deletion monai/metrics/rocauc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# limitations under the License.

import warnings
from typing import Union, cast, Callable, Optional
from typing import Callable, Optional, Union, cast

import numpy as np
import torch
Expand Down
1 change: 1 addition & 0 deletions monai/networks/blocks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .aspp import SimpleASPP
from .convolutions import Convolution, ResidualUnit
from .downsample import MaxAvgPool
from .fcn import FCN, GCN, MCFCN, Refine
from .squeeze_and_excitation import (
ChannelSELayer,
ResidualSELayer,
Expand Down
17 changes: 12 additions & 5 deletions monai/networks/blocks/convolutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Sequence, Union, Optional
from typing import Optional, Sequence, Union

import numpy as np
import torch
Expand Down Expand Up @@ -38,6 +38,10 @@ class Convolution(nn.Sequential):
act: activation type and arguments. Defaults to PReLU.
norm: feature normalization type and arguments. Defaults to instance norm.
dropout: dropout ratio. Defaults to no dropout.
dropout_dim: determine the dimensions of dropout. Defaults to 1.
When dropout_dim = 1, randomly zeroes some of the elements for each channel.
When dropout_dim = 2, Randomly zero out entire channels (a channel is a 2D feature map).
When dropout_dim = 3, Randomly zero out entire channels (a channel is a 3D feature map).
dilation: dilation rate. Defaults to 1.
groups: controls the connections between inputs and outputs. Defaults to 1.
bias: whether to have a bias term. Defaults to True.
Expand All @@ -64,6 +68,7 @@ def __init__(
act: Optional[Union[tuple, str]] = Act.PRELU,
norm: Union[tuple, str] = Norm.INSTANCE,
dropout: Optional[Union[int, float, tuple, str]] = None,
dropout_dim: int = 1,
dilation: Union[Sequence[int], int] = 1,
groups: int = 1,
bias: bool = True,
Expand Down Expand Up @@ -98,7 +103,7 @@ def __init__(
else:
drop_name, drop_args = split_args(dropout)

drop_type = Dropout[drop_name, dimensions]
drop_type = Dropout[drop_name, dropout_dim]
yiheng-wang-nv marked this conversation as resolved.
Show resolved Hide resolved

if is_transposed:
conv = conv_type(
Expand Down Expand Up @@ -167,9 +172,10 @@ def __init__(
strides: int = 1,
kernel_size: Union[Sequence[int], int] = 3,
subunits: int = 2,
act=Act.PRELU,
norm=Norm.INSTANCE,
dropout=None,
act: Optional[Union[tuple, str]] = Act.PRELU,
norm: Union[tuple, str] = Norm.INSTANCE,
dropout: Optional[Union[int, float, tuple, str]] = None,
dropout_dim: int = 1,
yiheng-wang-nv marked this conversation as resolved.
Show resolved Hide resolved
dilation: Union[Sequence[int], int] = 1,
bias: bool = True,
last_conv_only: bool = False,
Expand Down Expand Up @@ -197,6 +203,7 @@ def __init__(
act=act,
norm=norm,
dropout=dropout,
dropout_dim=dropout_dim,
dilation=dilation,
bias=bias,
conv_only=conv_only,
Expand Down
Loading