MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / AddMiDaS

Class AddMiDaS

ldm/data/util.py:6–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4
5
6class AddMiDaS(object):
7 def __init__(self, model_type):
8 super().__init__()
9 self.transform = load_midas_transform(model_type)
10
11 def pt2np(self, x):
12 x = ((x + 1.0) * .5).detach().cpu().numpy()
13 return x
14
15 def np2pt(self, x):
16 x = torch.from_numpy(x) * 2 - 1.
17 return x
18
19 def __call__(self, sample):
20 # sample['jpg'] is tensor hwc in [-1, 1] at this point
21 x = self.pt2np(sample['jpg'])
22 x = self.transform({"image": x})["image"]
23 sample['midas_in'] = x
24 return sample

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected