Repository navigation
⚠️ Breaking changes
- Python 3.10+ is required, and the minimum dependency versions went up:
torch>=1.11,torchvision>=0.12,numpy>=1.21.2,pillow>=8.4(#1281). - Encoder weights are downloaded only from the Hugging Face Hub. The old fallback to the original download URLs is gone, along with
smp.encoders.pretrained_settings. If you can't reach the Hub, setHF_ENDPOINTto a mirror or load weights from a local file (#1398). tu-encoders now warn whenencoder_weightsis a string. UseTrueorNone, and choose the pretrained variant in the name, e.g.tu-convnext_tiny.fb_in22k(#1269).
Highlights
Freeze and unfreeze the encoder
model = smp.Unet("resnet34")
model.freeze_encoder() # also stops BatchNorm running-stat updates
...
model.unfreeze_encoder()Losses
class_weightsforDiceLoss,JaccardLoss,TverskyLossandFocalLoss(multiclass and multilabel modes):loss = smp.losses.DiceLoss("multiclass", class_weights=[0.2, 1.0, 3.0])
FocalLossaccepts probabilities viafrom_logits=False, with anepsparameter likeDiceLoss.JaccardLosssupportsignore_index.- Losses work on non-contiguous tensors.
Models and encoders
- Transformer-style
tu-encoders work inUnetPlusPlusandLinknet(#1294). - PSPNet exports to ONNX (#1270).
- Fixed an MPS float tensor
ValueError(#1199).
What's Changed
-
Update no_grad usage to inference_mode by @GuillaumeErhard in #1164
-
Explicitly set
reductionfor Focal loss by @simonreise in #1165 -
Add
ignore_indexto Jaccard loss by @simonreise in #1151 -
Replaced
viewwithreplaceto prevent errors on non-contiguous tensors by @simonreise in #1174 -
Fix minor typo in dice.py by @snehilsanyal in #1181
-
Fix/issue 1198 value error invalid type torch.mps.float tensor by @Farbdrucker in #1199
-
Add missing name attribute to deeplabv3 & deeplabv3plus by @sanamorii in #1214
-
Add encoder_freeze method to SegmentationModel by @ricber in #1220
-
feat: Adding withoutBG by @kocabiyik in #1261
-
fix: TorchFix Errors by @isaaccorley in #1262
-
docs: Clarify tu- encoder_weights behavior as boolean flag by @GuillaumeErhard in #1269
-
CI: test Python 3.12+ by @adamjstewart in #1282
-
Python: bump minimum supported version to 3.10 by @adamjstewart in #1281
-
Codecov: don't comment on PRs by @adamjstewart in #1283
-
setuptools: adopt PEP 639 license metadata by @adamjstewart in #1280
-
Update HALLOFFAME.md with ICIP2025 results by @caglarmert in #1293
-
Docs: fix unexpected indentation around lists by @adamjstewart in #1297
-
Docs: fix title underline length by @adamjstewart in #1296
-
feat(losses): add class_weights support to Dice, Jaccard, Tversky and Focal losses by @lapertor in #1290
-
Docs: enable nitpicky mode and fix broken links by @adamjstewart in #1300
-
Docs: avoid duplicate target links by @adamjstewart in #1299
-
Add from_logits support to FocalLoss and eps for API consistency with DiceLoss by @Harsh-2005d in #1268
-
Support transformer-style tu- encoders in UnetPlusPlus and Linknet by @ShunsukeKikuchi in #1294
-
Docs: ignore encoders_dpt missing from any toctree by @adamjstewart in #1298
-
Docs: enable strict mode by @adamjstewart in #1301
-
Harden legacy URL fallback: pass weights_only=True to load_url by @mohammedix88 in #1393
-
Security hardening: http -> https by @adamjstewart in #1398
-
… plus 187 dependency updates by @dependabot
New Contributors
- @simonreise made their first contribution in #1165
- @snehilsanyal made their first contribution in #1181
- @Farbdrucker made their first contribution in #1199
- @sanamorii made their first contribution in #1214
- @ricber made their first contribution in #1220
- @isaaccorley made their first contribution in #1262
- @caglarmert made their first contribution in #1293
- @lapertor made their first contribution in #1270
- @Harsh-2005d made their first contribution in #1268
- @ShunsukeKikuchi made their first contribution in #1294
- @mohammedix88 made their first contribution in #1393
Full Changelog: v0.5.0...v0.6.0