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)
| 27 | |
| 28 | |
| 29 | def 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 | |
| 41 | class UnCLIPImageInterpolationPipeline(DiffusionPipeline): |