Releases: BloodAxe/pytorch-toolbelt
Pytorch Toolbelt 0.8.0
What's Changed
-
Merge pull request #97 from BloodAxe/develop by @BloodAxe in #98
-
Reduced focal loss implementation is incorrect for binary case by @MrPrajwalB in #102
New Contributors
- @MrPrajwalB made their first contribution in #102
Full Changelog: 0.7.0...0.8.0
Pytorch Toolbelt 0.7.0
New stuff
-
All encoders & decoders & heads are now inherit from
HasOutputFeaturesSpecificationinterface to query number of output channels and strides this module outputs. -
New loss class
QualityFocalLossfrom https://arxiv.org/abs/2006.04388 -
New function
pad_tensor_to_size-A generic padding function for N-dimensional tensors [B,C, ...] shape. -
Added
DropPathlayer (aka DropConnect) -
Pretrained weights for SegFormer backbones
-
first_class_background_initfor initializing last output convolution/linear block to have zeros in weights and bias layer set to[logit(bg_prob), logit(1-bg_prob), ...] -
New function
instantiate_normalization_blockto create normalization layer by name. This is used in some decoder layers / heads. -
Improvements
-
Improve numeric accuracy of
focal_loss_with_logitsfunction by explicitly disabling AMP autocast for this function and casting preds & targets tofloat32. -
MultiscaleTTAnow allows setting interpolationmodeandalign_cornersfor resizing input and predictions. -
BinaryFocalLossnow has__repr__ -
name_for_stridenow acceptsstrideargument to be None. In this case the function is noop and returns input argumentname. -
RandomSubsetDatasetnow takes optionalweightsargument to select samples with given probability.
Bugfixes
- Implementation of
get_collate_fnforRandomSubsetDatasetis not correct and returns collate function instead of calling it
Breaking Changes
-
Signature of decoders changes to require first argument
input_specto be of typeFeatureMapsSpecification. -
Rewritten BiFPN decoder to support arbitrary number of input feature maps, user-defined normalization & activation & BiFPN block.
-
Rewritten UNetDecoder to allow setting upsample block as string type
-
WeightedLossandJointLossclasses has been removed. If your code was using these classes here they are - copy paste them to your project and live happily, but I strongly suggest to use modern deep learning frameworks that support defining losses from configuration files.
class WeightedLoss(_Loss):
"""Wrapper class around loss function that applies weighted with fixed factor.
This class helps to balance multiple losses if they have different scales
"""
def __init__(self, loss, weight=1.0):
super().__init__()
self.loss = loss
self.weight = weight
def forward(self, *input):
return self.loss(*input) * self.weight
class JointLoss(_Loss):
"""
Wrap two loss functions into one. This class computes a weighted sum of two losses.
"""
def __init__(self, first: nn.Module, second: nn.Module, first_weight=1.0, second_weight=1.0):
super().__init__()
self.first = WeightedLoss(first, first_weight)
self.second = WeightedLoss(second, second_weight)
def forward(self, *input):
return self.first(*input) + self.second(*input)Pytorch Toolbelt 0.6.2
Merge pull request #89 from BloodAxe/develop 0.6.2
Pytorch Toolbelt 0.6.1
Pytorch Toolbelt 0.6.1
- Fixes to CI actions
- Adding support for python 3.10
- Bugfix in DatasetMeanStdCalculator when mask argument was used
PyTorch Toolbelt 0.6.0
Breaking Changes
All catalyst-related callbacks are moved to fork of the Catalyst library
PyTorch Toolbelt 0.5.3
Bugfixes
- Fix #78 thanks https://github.com/mehran66 for pointing this out
New Stuff
- InriaAerialImageDataset for working with Inria Aerial Dataset
get_collate_for_datasetfunction to get collate fn if a dataset instance (argument) exposesget_collate_fnmethod. Works also for ConcatDataset.
Improvements
DatasetMeanStdCalculatorsupportsdtypeto specify accumulator type (float64 by default)
PyTorch Toolbelt 0.5.2
BugFixes
- Fixed bug in
ApplySoftmaxToandApplySigmoidTomodules that could lead to activations not applied to input when it was a string
New API
- Added
fs.find_images_in_dir_recursive - Added
utils.describe_outputsto return a human-friendly representation of complex (dict, nested list, etc) outputs to see shape, mean/std of each tensor.
Other
More MyPy fixes & type annotations
PyTorch Toolbelt 0.5.1
New API
- Added
fs.find_subdirectories_in_dirto retrieve list of subdirectories (non-recursive) in the given directory. - Added
logoddaveraging of TTA predictions and counterpartlogodd_meanfunction.
Improvements
- In
plot_confusion_matrixone can disable plotting scores in each cell usingshow_scoresargument (Trueby default). freeze_modelmethod now returns inputmoduleargument.
PyTorch Toolbelt 0.5.0
Version 0.5.0
This is the major release update of Pytorch Toolbelt. It's been a long time since the last update and there are many improvements & updates since 0.4.4:
New features
- Added class
pytorch_toolbelt.datasets.DatasetMeanStdCalculatorto compute mean & std of the dataset that does not fit entirely in memory. - New decoder module:
BiFPNDecoder - New encoders:
SwinTransformer,SwinB,SwinL,SwinT,SwinS - Added
broadcast_from_masterfunction to distributed utils. This method allows scattering a tensor from the master node to all nodes. - Added
reduce_dict_sumto gather & concatenate dictionary of lists from all nodes in DDP. - Added
master_printas a drop-in replacement toprintthat prints to stdout only on the zero-rank node.
Bug Fixes
Breaking changes
- Bounding boxes matching method has been divided into two:
match_bboxesandmatch_bboxes_hungarian. The first method uses scores of predicted bboxes and matches most confident predictions first, while thematch_bboxes_hungarianmatches bboxes to maximize overall IoU. set_manual_seednow sets random seed for Numpy.to_numpynow correctly works for None and all iterables (Not only tuple & list)
Fixes & Improvements (NO BC)
- Added
dimargument toApplySoftmaxToto specify channel for softmax operator (default value is 1, which was hardcoded previously) ApplySigmoidTonow applies in-place sigmoid (Purely performance optimization)TileMergernow supports specifying adevice(Torch semantics) for storing intermediate tensors of accumulated tiles.- All TTA functions supports PyTorch Tracing
MultiscaleTTAnow supports a model that returns a single Tensor (Key-Value outputs still works as before)balanced_binary_cross_entropy_with_logitsandBalancedBCEWithLogitsLossnow supportsignore_indexargument.BiTemperedLogisticLoss&BinaryBiTemperedLogisticLossalso got support ofignore_indexargument.focal_loss_with_logitsnow also supportsignore_index. Computation of ignored values has been moved fromBinaryFocalLossto this function.- Reduced number of boilerplates & hardcoded code for encoders from
timm. NowGenericTimmEncoderqueries output strides & feature maps directly from thetimm's encoder instance. - HRNet-based encoders now have a
use_incre_featuresargument to specify whether output feature maps should have an increased number of features. change_extension,read_rgb_image,read_image_as_isfunctions now supportsPathas input argument. Return type (str) remains unchanged.count_parametersnow acceptshuman_friendlyargument to print parameters count in human-friendly form21.1Minstead 21123123.plot_confusion_matrixnow hasformat_stringargument (None by default) to specify custom format string for values in confusion matrix.RocAucMetricCallbackfor Catalyst gotfix_nansargument to fixNaNoutputs, which causedroc_aucto raise an exception and break the training.BestWorstMinerCallbacnow additionally logs batch withNaNvalue in monitored metric
PyTorch Toolbelt 0.4.4
New features
- New tiled processing classes for 3D data -
VolumeSlicerandVolumeMerger. Designed similarly toImageSlicer. Not you can run 3D segmentation on huge volumes without risk of OOM. - Support of labels (scalar or 1D vector) augmentation/deaugmentation in D2, D4 and flip-style TTA.
- Balanced BCE loss (
BalancedBCEWithLogitsLoss) - Bi-Tempered loss 'BiTemperedLogisticLoss'
SelectByIndexhelper module to pick named output of the model (For use innn.Sequential)- New encoders
MobileNetV3Large,MobileNetV3Smallfromtorchvision. - New encoders from
timmpackage (HRNets, ResNetD, EfficientNetV2 and others). - DeepLabV3 & DeepLabV3+ Decoders
- Pure
PyTorch-based implementation for bbox matching (match_bboxes) that supports both CPU/GPU matching using hungarian algorithm.
Bugfixes
Breaking Changes
- Parameter
ignorerenamed toignore_indexinBinaryLovaszLossclass. - Renamed
fpn_channelsargument in constructor ofFPNSumDecoderandFPNCatDecodertochannels. - Renamed 'output_channels
argument in constructor ofHRNetSegmentationDecoderto 'channels. conv1x1not set bias to zero by default- Bumped up minimal pytorch version to 1.8.1
Other Improvements
Ensemblerclass not correctly works withtorch.jit.tracing- Numerous docstrings & type annotations enchancements