Download pointcept/models/losses/builder.py from dfki-av/BIMStruct3D-segmentation: direct link, hf CLI and curl.
- Browser
- Download file 735 Bytes
-
https://huggingface.co/dfki-av/BIMStruct3D-segmentation/resolve/7ab05dd198d38ea08e60bb1e4f3f04aa369975c2/pointcept/models/losses/builder.py
- Command line
-
hf download hf://dfki-av/BIMStruct3D-segmentation@7ab05dd198d38ea08e60bb1e4f3f04aa369975c2/pointcept/models/losses/builder.py
-
curl -L -o builder.py https://huggingface.co/dfki-av/BIMStruct3D-segmentation/resolve/7ab05dd198d38ea08e60bb1e4f3f04aa369975c2/pointcept/models/losses/builder.py
735 Bytes
| """ | |
| Criteria Builder | |
| Author: Xiaoyang Wu (xiaoyang.wu.cs@gmail.com) | |
| Please cite our work if the code is helpful to you. | |
| """ | |
| from pointcept.utils.registry import Registry | |
| LOSSES = Registry("losses") | |
| class Criteria(object): | |
| def __init__(self, cfg=None): | |
| self.cfg = cfg if cfg is not None else [] | |
| self.criteria = [] | |
| for loss_cfg in self.cfg: | |
| self.criteria.append(LOSSES.build(cfg=loss_cfg)) | |
| def __call__(self, pred, target): | |
| if len(self.criteria) == 0: | |
| # loss computation occur in model | |
| return pred | |
| loss = 0 | |
| for c in self.criteria: | |
| loss += c(pred, target) | |
| return loss | |
| def build_criteria(cfg): | |
| return Criteria(cfg) | |