MCPcopy Create free account
hub / github.com/ZhengPeng7/BiRefNet / __init__

Method __init__

loss.py:158–179  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

156 Pixel loss for each refined map output.
157 """
158 def __init__(self):
159 super(PixLoss, self).__init__()
160 self.config = Config()
161 self.lambdas_pix_last = self.config.lambdas_pix_last
162
163 self.criterions_last = {}
164 if 'bce' in self.lambdas_pix_last and self.lambdas_pix_last['bce']:
165 self.criterions_last['bce'] = nn.BCELoss()
166 if 'iou' in self.lambdas_pix_last and self.lambdas_pix_last['iou']:
167 self.criterions_last['iou'] = IoULoss()
168 if 'iou_patch' in self.lambdas_pix_last and self.lambdas_pix_last['iou_patch']:
169 self.criterions_last['iou_patch'] = PatchIoULoss()
170 if 'ssim' in self.lambdas_pix_last and self.lambdas_pix_last['ssim']:
171 self.criterions_last['ssim'] = SSIMLoss()
172 if 'mse' in self.lambdas_pix_last and self.lambdas_pix_last['mse']:
173 self.criterions_last['mse'] = nn.MSELoss()
174 if 'reg' in self.lambdas_pix_last and self.lambdas_pix_last['reg']:
175 self.criterions_last['reg'] = ThrReg_loss()
176 if 'cnt' in self.lambdas_pix_last and self.lambdas_pix_last['cnt']:
177 self.criterions_last['cnt'] = ContourLoss()
178 if 'structure' in self.lambdas_pix_last and self.lambdas_pix_last['structure']:
179 self.criterions_last['structure'] = StructureLoss()
180
181 def forward(self, scaled_preds, gt):
182 loss = 0.

Callers

nothing calls this directly

Calls 8

ConfigClass · 0.90
IoULossClass · 0.85
PatchIoULossClass · 0.85
SSIMLossClass · 0.85
ThrReg_lossClass · 0.85
ContourLossClass · 0.85
StructureLossClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected