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

Generelize UNet: custom # of input channels (instead of default 3) #297

Merged
merged 2 commits into from
Oct 28, 2020
Merged
Changes from 1 commit
Commits
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
4 changes: 3 additions & 1 deletion pl_bolts/models/vision/unet.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,23 @@ class UNet(nn.Module):

Args:
num_classes: Number of output classes required
input_channels: Number of channels in input images (default 3)
num_layers: Number of layers in each side of U-net (default 5)
features_start: Number of features in first layer (default 64)
bilinear (bool): Whether to use bilinear interpolation or transposed convolutions (default) for upsampling.
annikabrundyn marked this conversation as resolved.
Show resolved Hide resolved
"""
def __init__(
self,
num_classes: int,
input_channels: int = 3,
num_layers: int = 5,
features_start: int = 64,
bilinear: bool = False
):
super().__init__()
self.num_layers = num_layers

layers = [DoubleConv(3, features_start)]
layers = [DoubleConv(input_channels, features_start)]

feats = features_start
for _ in range(num_layers - 1):
Expand Down