MCPcopy Create free account
hub / github.com/ali-vilab/VACE / load_image_batch

Method load_image_batch

vace/models/utils/preprocessor.py:70–85  ·  view source on GitHub ↗
(self, *data_key_batch, normalize=True, seq_len=None, **kwargs)

Source from the content-addressed store, hash-verified

68 return self.load_image_batch(data_key, data_key2, **kwargs)
69
70 def load_image_batch(self, *data_key_batch, normalize=True, seq_len=None, **kwargs):
71 seq_len = self.seq_len if seq_len is None else seq_len
72 imgs = []
73 for data_key in data_key_batch:
74 img = self._load_image(data_key)
75 imgs.append(img)
76 w, h = imgs[0].size
77 dh, dw = self.downsample[1:]
78
79 # compute output size
80 scale = min(1., np.sqrt(seq_len / ((h / dh) * (w / dw))))
81 oh = int(h * scale) // dh * dh
82 ow = int(w * scale) // dw * dw
83 assert (oh // dh) * (ow // dw) <= seq_len
84 imgs = [self._image_preprocess(img, oh, ow, normalize) for img in imgs]
85 return *imgs, (oh, ow)
86
87
88class VaceVideoProcessor(object):

Callers 2

load_imageMethod · 0.95
load_image_pairMethod · 0.95

Calls 2

_load_imageMethod · 0.95
_image_preprocessMethod · 0.95

Tested by

no test coverage detected