MCPcopy Create free account
hub / github.com/FreeformRobotics/OTS / SegmentationModuleBase

Class SegmentationModuleBase

models/models.py:8–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6
7
8class SegmentationModuleBase(nn.Module):
9 def __init__(self):
10 super(SegmentationModuleBase, self).__init__()
11
12 def pixel_acc(self, pred, label):
13 _, preds = torch.max(pred, dim=1)
14 valid = (label >= 0).long()
15 acc_sum = torch.sum(valid * (preds == label).long())
16 pixel_sum = torch.sum(valid)
17 acc = acc_sum.float() / (pixel_sum.float() + 1e-10)
18 return acc
19
20
21class SegmentationModule(SegmentationModuleBase):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected