MCPcopy
hub / github.com/Stability-AI/generative-models / append_dims

Function append_dims

sgm/util.py:192–199  ·  view source on GitHub ↗

Appends dimensions to the end of a tensor until it has target_dims dimensions.

(x, target_dims)

Source from the content-addressed store, hash-verified

190
191
192def append_dims(x, target_dims):
193 """Appends dimensions to the end of a tensor until it has target_dims dimensions."""
194 dims_to_append = target_dims - x.ndim
195 if dims_to_append < 0:
196 raise ValueError(
197 f"input has {x.ndim} dims but target_dims is {target_dims}, which is less"
198 )
199 return x[(...,) + (None,) * dims_to_append]
200
201
202def load_model_from_config(config, ckpt, verbose=True, freeze=True):

Callers 11

do_img2imgFunction · 0.90
do_img2imgFunction · 0.90
__call__Method · 0.85
to_dFunction · 0.85
sampler_stepMethod · 0.85
ancestral_euler_stepMethod · 0.85
ancestral_stepMethod · 0.85
sampler_stepMethod · 0.85
sampler_stepMethod · 0.85
__call__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected