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

Backbone of FBA. #215

Merged
merged 34 commits into from
Mar 4, 2021
Merged

Backbone of FBA. #215

merged 34 commits into from
Mar 4, 2021

Conversation

yaochaorui
Copy link
Contributor

No description provided.

@yaochaorui yaochaorui requested a review from innerlee March 1, 2021 04:15
@innerlee innerlee requested a review from hejm37 March 1, 2021 04:22
@codecov
Copy link

codecov bot commented Mar 1, 2021

Codecov Report

Merging #215 (b83f4c7) into master (41c1a49) will decrease coverage by 0.56%.
The diff coverage is 70.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #215      +/-   ##
==========================================
- Coverage   82.27%   81.71%   -0.57%     
==========================================
  Files         145      148       +3     
  Lines        6732     7055     +323     
  Branches     1004     1047      +43     
==========================================
+ Hits         5539     5765     +226     
- Misses       1086     1171      +85     
- Partials      107      119      +12     
Flag Coverage Δ
unittests 81.71% <70.33%> (-0.57%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmedit/models/backbones/__init__.py 100.00% <ø> (ø)
mmedit/models/mattors/utils.py 41.17% <20.00%> (-30.26%) ⬇️
mmedit/datasets/pipelines/normalization.py 89.47% <33.33%> (-10.53%) ⬇️
...ckbones/encoder_decoders/simple_encoder_decoder.py 94.44% <50.00%> (-5.56%) ⬇️
...dels/backbones/encoder_decoders/encoders/resnet.py 66.98% <66.98%> (ø)
...backbones/encoder_decoders/decoders/fba_decoder.py 82.08% <82.08%> (ø)
...backbones/encoder_decoders/encoders/fba_encoder.py 92.00% <92.00%> (ø)
mmedit/datasets/pipelines/matting_aug.py 94.25% <100.00%> (+0.02%) ⬆️
...edit/models/backbones/encoder_decoders/__init__.py 100.00% <100.00%> (ø)
...ls/backbones/encoder_decoders/decoders/__init__.py 100.00% <100.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 41c1a49...fd8954b. Read the comment docs.

batch_norm=False,
norm_cfg=None,
act_cfg=dict(type='ReLU')):
super(FBADecoder, self).__init__()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super().__init__()

x = torch.cat((x, conv_out[-6][:, :3], img, two_chan_trimap), 1)

output = self.conv_up4(x)
alpha = torch.clamp(output[:, 0][:, None], 0, 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[:, 0][:, None] -> [:, 0:1]

@@ -0,0 +1,119 @@
import torch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Give credit if the code is modified from the original code

norm(256, self.batch_norm), nn.LeakyReLU())

# Keep the batch_norm here in case we may need to modify something
if (self.batch_norm):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

superfluous brackets

ConvWS2d(256 + 256, 256, kernel_size=3, padding=1, bias=True),
norm(256, self.batch_norm), nn.LeakyReLU())

# Keep the batch_norm here in case we may need to modify something
Copy link
Contributor

@innerlee innerlee Mar 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case we may need to modify something

What does this line of comment mean

nn.Conv2d(16, 7, kernel_size=1, padding=0, bias=True))

def init_weights(self, pretrained=None):
pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this pass intended?

def forward(self, inputs):
"""Forward function.
Args:
inputs (dict): Output dict of FbaEncoder.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enocder or decoder?


conv_out = inputs['conv_out']
img = inputs['merged']
two_chan_trimap = inputs['two_chan_trimap']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two_chan_trimap -> two_channel_trimap

nn.Sequential(
nn.AdaptiveAvgPool2d(scale),
ConvWS2d(2048, 256, kernel_size=1, bias=True),
norm(256, self.batch_norm), nn.LeakyReLU()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why norm_cfg and act_cfg are needed if all are hard-coded as batch_norm and LeakyReLU



def norm(dim, bn=False):
if (bn):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove brackets

return out


class ResNet(nn.Module):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResNet -> ResNetFBA

}


def l_resnet50(pretrained=None, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name is cryptic

@innerlee innerlee merged commit c86ae42 into master Mar 4, 2021
@innerlee innerlee deleted the ycr/backbone branch March 4, 2021 13:37
Yshuo-Li pushed a commit to Yshuo-Li/mmediting that referenced this pull request Jul 15, 2022
* Backbone of FBA.

* Init.

* Doc string for forward.

* Doc string of Init.

* Modified API.

* FBAencoder.

* Tiny.

* Doc string.

* Decoder.

* Init.

* General Res.

* Added test.

* Added tests.

* Added two_channel_trimap key.

* Tiny.

* Restore shape.

* Tiny.

* Added utis. May change.

* Added FBA mattor.

* Improved.

* Tiny.

* Modified.

* Tiny.

* Tiny.

* Tiny.

* Delete plugins.

* Modified.

* Tiny.

* Mattor.

* Tiny.

* Tiny.

* Postponed to next branch.

* Tiny.

* Update base_mattor.py

Co-authored-by: lizz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants