Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

Commit 8f8af8b

Browse files
committed
ImageToAnimation process started
1 parent 69f2993 commit 8f8af8b

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
}

OnnxStack.StableDiffusion/Enums/DiffuserType.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ public enum DiffuserType
55
TextToImage = 0,
66
ImageToImage = 1,
77
ImageInpaint = 2,
8-
ImageInpaintLegacy = 3
8+
ImageInpaintLegacy = 3,
9+
ImageToAnimation = 4,
910
}
1011
}

0 commit comments

Comments
 (0)