MCPcopy Create free account
hub / github.com/CompVis/diff2flow / CenterCropResize

Class CenterCropResize

diff2flow/dataset/image_preprocessing.py:6–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4
5
6class CenterCropResize(nn.Module):
7 def __init__(self, size):
8 super().__init__()
9 self.size = size
10
11 def forward(self, x):
12 h, w = x.shape[-2:]
13 min_size = min(h, w)
14 crop = T.functional.center_crop(x, min_size)
15 x = T.functional.resize(crop, self.size, antialias=True)
16 return x
17
18
19class RescaleDiffusersLatent:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected