MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / slerp

Function slerp

diffusers/examples/community/unclip_image_interpolation.py:29–38  ·  view source on GitHub ↗

Find the interpolation point between the 'low' and 'high' values for the given 'val'. See https://en.wikipedia.org/wiki/Slerp for more details on the topic.

(val, low, high)

Source from the content-addressed store, hash-verified

27
28
29def slerp(val, low, high):
30 """
31 Find the interpolation point between the 'low' and 'high' values for the given 'val'. See https://en.wikipedia.org/wiki/Slerp for more details on the topic.
32 """
33 low_norm = low / torch.norm(low)
34 high_norm = high / torch.norm(high)
35 omega = torch.acos((low_norm * high_norm))
36 so = torch.sin(omega)
37 res = (torch.sin((1.0 - val) * omega) / so) * low + (torch.sin(val * omega) / so) * high
38 return res
39
40
41class UnCLIPImageInterpolationPipeline(DiffusionPipeline):

Callers 1

__call__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected