-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use imagenet pretrained model & add a baseline unet as reference
- add a batch-norm layer for the tinycd model - add a unet model for reference - use efficientnet model pretrained on imagenet - reduce the `pos_weight` for bce loss to 5.0
- Loading branch information
SRM
committed
May 31, 2023
1 parent
1b59e8a
commit 75c6d28
Showing
4 changed files
with
65 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import torch | ||
import torch.nn as nn | ||
import segmentation_models_pytorch as smp | ||
|
||
|
||
class UnetChangeClassifier(nn.Module): | ||
def __init__(self, in_channels=6, out_channels=1): | ||
super().__init__() | ||
self.model = smp.Unet( | ||
encoder_name="timm-efficientnet-b0", | ||
encoder_weights="imagenet", | ||
in_channels=in_channels, | ||
classes=out_channels, | ||
activation=None, | ||
) | ||
self.normalize = nn.BatchNorm2d(in_channels) | ||
|
||
def forward(self, x1: torch.Tensor, x2: torch.Tensor) -> torch.Tensor: | ||
x = torch.cat([x1, x2], dim=1) | ||
x = self.normalize(x) | ||
return self.model(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters