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)
| 23 | |
| 24 | |
| 25 | def 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 | |
| 37 | class UnCLIPTextInterpolationPipeline(DiffusionPipeline): |