MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / shave_segments

Function shave_segments

scripts/convert_unidiffuser_to_diffusers.py:37–44  ·  view source on GitHub ↗

Removes segments. Positive values shave the first segments, negative shave the last segments.

(path, n_shave_prefix_segments=1)

Source from the content-addressed store, hash-verified

35
36# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.shave_segments
37def shave_segments(path, n_shave_prefix_segments=1):
38 """
39 Removes segments. Positive values shave the first segments, negative shave the last segments.
40 """
41 if n_shave_prefix_segments >= 0:
42 return ".".join(path.split(".")[n_shave_prefix_segments:])
43 else:
44 return ".".join(path.split(".")[:n_shave_prefix_segments])
45
46
47# Copied from diffusers.pipelines.stable_diffusion.convert_from_ckpt.renew_vae_resnet_paths

Callers 2

renew_vae_resnet_pathsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected