forked from remotebiosensing/rppg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jinsoo Kim
committed
Aug 10, 2021
1 parent
3121c35
commit 666b4a4
Showing
3 changed files
with
54 additions
and
31 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 |
---|---|---|
@@ -1,35 +1,65 @@ | ||
import torch.nn | ||
|
||
from nets.blocks.blocks import ConvBlock2D | ||
from nets.blocks.blocks import ConvBlock3D | ||
|
||
|
||
class cnn_blocks(torch.nn.Module): | ||
def __init__(self): | ||
super(cnn_blocks, self).__init__() | ||
self.cnn_blocks = torch.nn.Sequential( | ||
ConvBlock3D(3, 16, [1, 5, 5], [1, 1, 1], [0, 2, 2]), | ||
torch.nn.MaxPool3d((1, 2, 2), stride=(1, 2, 2)), | ||
ConvBlock3D(16, 32, [1, 3, 3], [1, 1, 1], [1, 1, 1]), | ||
ConvBlock3D(32, 64, [1, 3, 3], [1, 1, 1], [1, 1, 1]), | ||
torch.nn.MaxPool3d((1, 2, 2), stride=(1, 2, 2)), | ||
ConvBlock3D(64, 64, [1, 3, 3], [1, 1, 1], [1, 1, 1]), | ||
ConvBlock3D(64, 64, [1, 3, 3], [1, 1, 1], [1, 1, 1]), | ||
torch.nn.MaxPool3d((1, 2, 2), stride=(1, 2, 2)), | ||
ConvBlock3D(64, 64, [1, 3, 3], [1, 1, 1], [1, 1, 1]), | ||
ConvBlock3D(64, 64, [1, 3, 3], [1, 1, 1], [1, 1, 1]), | ||
torch.nn.MaxPool3d((1, 2, 2), stride=(1, 2, 2)), | ||
ConvBlock3D(64, 64, [1, 3, 3], [1, 1, 1], [1, 1, 1]), | ||
ConvBlock3D(64, 64, [1, 3, 3], [1, 1, 1], [1, 1, 1]), | ||
# torch.nn.AdaptiveMaxPool3d(1) | ||
ConvBlock2D(3, 16, [5, 5], [1, 1], [2, 2]), | ||
torch.nn.MaxPool2d((2, 2), stride=(2, 2)), | ||
ConvBlock2D(16, 32, [3, 3], [1, 1], [1, 1]), | ||
ConvBlock2D(32, 64, [3, 3], [1, 1], [1, 1]), | ||
torch.nn.MaxPool2d((2, 2), stride=(2, 2)), | ||
ConvBlock2D(64, 64, [3, 3], [1, 1], [1, 1]), | ||
ConvBlock2D(64, 64, [3, 3], [1, 1], [1, 1]), | ||
torch.nn.MaxPool2d((2, 2), stride=(2, 2)), | ||
ConvBlock2D(64, 64, [3, 3], [1, 1], [1, 1]), | ||
ConvBlock2D(64, 64, [3, 3], [1, 1], [1, 1]), | ||
torch.nn.MaxPool2d((2, 2), stride=(2, 2)), | ||
ConvBlock2D(64, 64, [3, 3], [1, 1], [1, 1]), | ||
ConvBlock2D(64, 64, [3, 3], [1, 1], [1, 1]), | ||
torch.nn.AdaptiveMaxPool2d(1) | ||
) | ||
|
||
def forward(self, x): | ||
[batch, channel, length, width, height] = x.shape | ||
# x = x.reshape(batch * length, channel, width, height) | ||
# x = self.cnn_blocks(x) | ||
# x = x.reshape(batch,length,-1,1,1) | ||
x = x.view(batch * length, channel, width, height) | ||
x = self.cnn_blocks(x) | ||
x = x.view(batch,length,-1,1,1) | ||
|
||
return x | ||
|
||
''' | ||
Conv3D 1x3x3(paper architecture) | ||
''' | ||
# class cnn_blocks(torch.nn.Module): | ||
# def __init__(self): | ||
# super(cnn_blocks, self).__init__() | ||
# self.cnn_blocks = torch.nn.Sequential( | ||
# ConvBlock3D(3, 16, [1, 5, 5], [1, 1, 1], [0, 2, 2]), | ||
# torch.nn.MaxPool3d((1, 2, 2), stride=(1, 2, 2)), | ||
# ConvBlock3D(16, 32, [1, 3, 3], [1, 1, 1], [1, 1, 1]), | ||
# ConvBlock3D(32, 64, [1, 3, 3], [1, 1, 1], [1, 1, 1]), | ||
# torch.nn.MaxPool3d((1, 2, 2), stride=(1, 2, 2)), | ||
# ConvBlock3D(64, 64, [1, 3, 3], [1, 1, 1], [1, 1, 1]), | ||
# ConvBlock3D(64, 64, [1, 3, 3], [1, 1, 1], [1, 1, 1]), | ||
# torch.nn.MaxPool3d((1, 2, 2), stride=(1, 2, 2)), | ||
# ConvBlock3D(64, 64, [1, 3, 3], [1, 1, 1], [1, 1, 1]), | ||
# ConvBlock3D(64, 64, [1, 3, 3], [1, 1, 1], [1, 1, 1]), | ||
# torch.nn.MaxPool3d((1, 2, 2), stride=(1, 2, 2)), | ||
# ConvBlock3D(64, 64, [1, 3, 3], [1, 1, 1], [1, 1, 1]), | ||
# ConvBlock3D(64, 64, [1, 3, 3], [1, 1, 1], [1, 1, 1]), | ||
# # torch.nn.AdaptiveMaxPool3d(1) | ||
# ) | ||
# | ||
# def forward(self, x): | ||
# [batch, channel, length, width, height] = x.shape | ||
# # x = x.reshape(batch * length, channel, width, height) | ||
# # x = self.cnn_blocks(x) | ||
# # x = x.reshape(batch,length,-1,1,1) | ||
# x = self.cnn_blocks(x) | ||
# | ||
# return 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
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