feat: Initial commit

This commit is contained in:
fdyuandong
2025-04-17 23:14:24 +08:00
commit ca93dd0572
51 changed files with 7904 additions and 0 deletions

28
models/losses/builder.py Normal file
View File

@@ -0,0 +1,28 @@
"""
The code is base on https://github.com/Pointcept/Pointcept
"""
from 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)