-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from discovery-unicamp/perlin-noise
Perlin noise
- Loading branch information
Showing
4 changed files
with
136 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,6 @@ statsmodels | |
tifffile | ||
torch | ||
zarr | ||
torchmetrics | ||
rich | ||
perlin-noise | ||
torchmetrics |
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,54 @@ | ||
import torch | ||
import torch.nn as nn | ||
import torch.nn.functional as F | ||
import lightning as L | ||
from torchvision import models | ||
|
||
from .base import SimpleSupervisedModel | ||
|
||
class Resnet50Backbone(nn.Module): | ||
|
||
def __init__(self) -> None: | ||
super().__init__() | ||
self.resnet50 = models.resnet50() | ||
self.resnet50 = nn.Sequential(*list(self.resnet50.children())[:-2]) | ||
|
||
def forward(self, x): | ||
return self.resnet50(x) | ||
|
||
class DeepLabV3_Head(nn.Module): | ||
|
||
def __init__(self) -> None: | ||
super().__init__() | ||
raise NotImplementedError("DeepLabV3's head has not yet been implemented") | ||
|
||
def forward(self, x): | ||
raise NotImplementedError("DeepLabV3's head has not yet been implemented") | ||
|
||
|
||
class DeepLabV3(SimpleSupervisedModel): | ||
|
||
"""A DeeplabV3 with a ResNet50 backbone | ||
References | ||
---------- | ||
Liang-Chieh Chen, George Papandreou, Florian Schroff, Hartwig Adam. "Rethinking Atrous Convolution for Semantic Image Segmentation", 2017 | ||
""" | ||
|
||
def __init__(self, learning_rate: float = 1e-3,loss_fn: torch.nn.Module = None): | ||
"""Wrapper implementation of the DeepLabv3 model. | ||
Parameters | ||
---------- | ||
learning_rate : float, optional | ||
The learning rate to Adam optimizer, by default 1e-3 | ||
loss_fn : torch.nn.Module, optional | ||
The function used to compute the loss. If `None`, it will be used | ||
the MSELoss, by default None. | ||
""" | ||
super().__init__( | ||
backbone=Resnet50Backbone(), | ||
fc=DeepLabV3_Head(), | ||
loss_fn=loss_fn or torch.nn.MSELoss(), | ||
learning_rate=learning_rate, | ||
) |
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