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

Function slerp

diffusers/examples/community/unclip_text_interpolation.py:25–34  ·  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

23
24
25def slerp(val, low, high):
26 """
27 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.
28 """
29 low_norm = low / torch.norm(low)
30 high_norm = high / torch.norm(high)
31 omega = torch.acos((low_norm * high_norm))
32 so = torch.sin(omega)
33 res = (torch.sin((1.0 - val) * omega) / so) * low + (torch.sin(val * omega) / so) * high
34 return res
35
36
37class UnCLIPTextInterpolationPipeline(DiffusionPipeline):

Callers 1

__call__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected