|
| 1 | +using Microsoft.ML.OnnxRuntime.Tensors; |
| 2 | +using OnnxStack.Core.Services; |
| 3 | +using OnnxStack.StableDiffusion.Common; |
| 4 | +using OnnxStack.StableDiffusion.Config; |
| 5 | +using System; |
| 6 | +using System.Collections.Generic; |
| 7 | +using System.Linq; |
| 8 | +using System.Text; |
| 9 | +using System.Threading.Tasks; |
| 10 | + |
| 11 | +namespace OnnxStack.StableDiffusion.Diffusers |
| 12 | +{ |
| 13 | + public class AnimateDiffuser : DiffuserBase |
| 14 | + { |
| 15 | + |
| 16 | + /// <summary> |
| 17 | + /// Initializes a new instance of the <see cref="AnimateDiffuser"/> class. |
| 18 | + /// </summary> |
| 19 | + /// <param name="onnxModelService">The onnx model service.</param> |
| 20 | + /// <param name="promptService"></param> |
| 21 | + public AnimateDiffuser(IOnnxModelService onnxModelService, IPromptService promptService) |
| 22 | + : base(onnxModelService, promptService) { } |
| 23 | + |
| 24 | + |
| 25 | + /// <summary> |
| 26 | + /// Gets the timesteps. |
| 27 | + /// </summary> |
| 28 | + /// <param name="prompt">The prompt.</param> |
| 29 | + /// <param name="options">The options.</param> |
| 30 | + /// <param name="scheduler">The scheduler.</param> |
| 31 | + /// <returns></returns> |
| 32 | + protected override IReadOnlyList<int> GetTimesteps(PromptOptions prompt, SchedulerOptions options, IScheduler scheduler) |
| 33 | + { |
| 34 | + return scheduler.Timesteps; |
| 35 | + } |
| 36 | + |
| 37 | + |
| 38 | + /// <summary> |
| 39 | + /// Prepares the latents. |
| 40 | + /// </summary> |
| 41 | + /// <param name="model"></param> |
| 42 | + /// <param name="prompt">The prompt.</param> |
| 43 | + /// <param name="options">The options.</param> |
| 44 | + /// <param name="scheduler">The scheduler.</param> |
| 45 | + /// <param name="timesteps">The timesteps.</param> |
| 46 | + /// <returns></returns> |
| 47 | + protected override DenseTensor<float> PrepareLatents(IModelOptions model, PromptOptions prompt, SchedulerOptions options, IScheduler scheduler, IReadOnlyList<int> timesteps) |
| 48 | + { |
| 49 | + return scheduler.CreateRandomSample(options.GetScaledDimension(prompt.BatchCount), scheduler.InitNoiseSigma); |
| 50 | + } |
| 51 | + } |
| 52 | +} |
0 commit comments