-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: TorchFix Errors #1262
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
base: main
Are you sure you want to change the base?
fix: TorchFix Errors #1262
Conversation
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.
Pull request overview
This PR addresses deprecation warnings from the torchfix linter by replacing deprecated PyTorch functions with their modern equivalents. The changes improve code accuracy and prevent future compatibility issues.
- Replaced
torch.nn.UpsamplingBilinear2dwithtorch.nn.Upsample(mode="bilinear")in two locations - Replaced
torch.log(1 + x)withtorch.log1p(x)for improved numerical accuracy
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| segmentation_models_pytorch/base/heads.py | Updated upsampling layer to use non-deprecated API |
| segmentation_models_pytorch/decoders/deeplabv3/decoder.py | Updated upsampling layer to use non-deprecated API |
| segmentation_models_pytorch/losses/_functional.py | Improved numerical accuracy in wing loss calculation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
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.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ) | ||
| upsampling = ( | ||
| nn.UpsamplingBilinear2d(scale_factor=upsampling) | ||
| nn.Upsample(mode="bilinear", scale_factor=upsampling, align_corners=True) |
Copilot
AI
Dec 1, 2025
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.
Setting align_corners=True changes the upsampling behavior compared to the deprecated UpsamplingBilinear2d which used align_corners=False by default. This could affect model output and should be verified against existing trained models. Consider using align_corners=False to maintain backward compatibility unless the behavior change is intentional.
| nn.Upsample(mode="bilinear", scale_factor=upsampling, align_corners=True) | |
| nn.Upsample(mode="bilinear", scale_factor=upsampling, align_corners=False) |
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.
@isaaccorley can we keep the previous behaviour with align_corners=False?
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.
I actually tried this initially but this caused the logit tests to fail. I believe this means that the original pretrained checkpoints used align_corners=True.
qubvel
left a comment
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 update! Just a question re align corners
| ) | ||
| upsampling = ( | ||
| nn.UpsamplingBilinear2d(scale_factor=upsampling) | ||
| nn.Upsample(mode="bilinear", scale_factor=upsampling, align_corners=True) |
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.
@isaaccorley can we keep the previous behaviour with align_corners=False?
Running the torchfix linter results in the following errors. This PR fixes these.