-
Notifications
You must be signed in to change notification settings - Fork 7k
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
fix: atrous_rates for deeplabv3_mobilenet_v3_large (fixes #7956) #8019
Conversation
Hi @nvs-abhilash! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @nvs-abhilash .
I made a few comments below regarding preserving backward compatibility.
@fmassa , do you remember why the values [12, 24, 36]
were used for the atrous rates in #820, instead of [6, 12, 18]
?
@@ -220,7 +220,7 @@ def _deeplabv3_mobilenetv3( | |||
backbone = IntermediateLayerGetter(backbone, return_layers=return_layers) | |||
|
|||
aux_classifier = FCNHead(aux_inplanes, num_classes) if aux else None | |||
classifier = DeepLabHead(out_inplanes, num_classes) | |||
classifier = DeepLabHead(out_inplanes, num_classes, atrous_rates=(6, 12, 18)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this would be BC-breaking. We'll have to preserve the values that are currently used here (relying on the default).
classifier = DeepLabHead(out_inplanes, num_classes, atrous_rates=(6, 12, 18)) | |
classifier = DeepLabHead(out_inplanes, num_classes) |
@@ -83,7 +83,7 @@ def forward(self, x: torch.Tensor) -> torch.Tensor: | |||
|
|||
|
|||
class ASPP(nn.Module): | |||
def __init__(self, in_channels: int, atrous_rates: List[int], out_channels: int = 256) -> None: | |||
def __init__(self, in_channels: int, atrous_rates: Tuple[int, int, int], out_channels: int = 256) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my understanding, using List[int]
instead of a fixed 3-tuple was intended (details in #2136).
def __init__(self, in_channels: int, atrous_rates: Tuple[int, int, int], out_channels: int = 256) -> None: | |
def __init__(self, in_channels: int, atrous_rates: List[int], out_channels: int = 256) -> None: |
@@ -46,9 +46,9 @@ class DeepLabV3(_SimpleSegmentationModel): | |||
|
|||
|
|||
class DeepLabHead(nn.Sequential): | |||
def __init__(self, in_channels: int, num_classes: int) -> None: | |||
def __init__(self, in_channels: int, num_classes: int, atrous_rates: Tuple[int, int, int] = (12, 24, 36)) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def __init__(self, in_channels: int, num_classes: int, atrous_rates: Tuple[int, int, int] = (12, 24, 36)) -> None: | |
def __init__(self, in_channels: int, num_classes: int, atrous_rates: List[int] = [12, 24, 36]) -> None: |
Hi, Thanks for the PR! The dilation rates could have been an oversight when porting the DeepLab head into MobileNetV3. Changing the defaults will change the outputs produced by the models, so I agree with @NicolasHug to keep the same defaults as before. |
73ef094
to
17b530d
Compare
Thanks, @NicolasHug and @fmassa for reviewing my code. Post your comments, the only change that seems to make sense is just to parameterise the Also, what can be the path to solve #7956 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nvs-abhilash , LGTM with one last comment below
@@ -46,9 +46,9 @@ class DeepLabV3(_SimpleSegmentationModel): | |||
|
|||
|
|||
class DeepLabHead(nn.Sequential): | |||
def __init__(self, in_channels: int, num_classes: int) -> None: | |||
def __init__(self, in_channels: int, num_classes: int, atrous_rates: List[int] = [12, 24, 36]) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid setting mutables as default values in general as there's a risk that we will change that value inplace, and subsequent calls would be using the wrong default.
def __init__(self, in_channels: int, num_classes: int, atrous_rates: List[int] = [12, 24, 36]) -> None: | |
def __init__(self, in_channels: int, num_classes: int, atrous_rates: Sequence[int] = (12, 24, 36)) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, makes sense. I thought the same, therefore had made it tuple before. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the PR.
Would documenting the atrous rates being used be enough? |
17b530d
to
67dce75
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @nvs-abhilash
Hey @NicolasHug! You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py |
) (#8019) Summary: Co-authored-by: Nicolas Hug <nh.nicolas.hug@gmail.com> Reviewed By: vmoens Differential Revision: D50789082 fbshipit-source-id: 02bbe21ba09522b2db1552c6a677b89ff4247392
This PR addresses the issue reffered in #7956
The PR proposes the following changes to address the issues:
DeepLabHead
.Send (6, 12, 18) atrous_rates for mobilenet backbone