1
1
using Microsoft . ML . OnnxRuntime . Tensors ;
2
+ using OnnxStack . Core . Config ;
2
3
using OnnxStack . StableDiffusion . Config ;
3
4
using OnnxStack . StableDiffusion . Models ;
4
5
using SixLabors . ImageSharp ;
@@ -18,15 +19,15 @@ public interface IStableDiffusionService
18
19
/// </summary>
19
20
/// <param name="modelOptions">The model options.</param>
20
21
/// <returns></returns>
21
- Task < bool > LoadModelAsync ( StableDiffusionModelSet model ) ;
22
+ Task < bool > LoadModelAsync ( IOnnxModelSetConfig model ) ;
22
23
23
24
24
25
/// <summary>
25
26
/// Unloads the model.
26
27
/// </summary>
27
28
/// <param name="modelOptions">The model options.</param>
28
29
/// <returns></returns>
29
- Task < bool > UnloadModelAsync ( StableDiffusionModelSet model ) ;
30
+ Task < bool > UnloadModelAsync ( IOnnxModel model ) ;
30
31
31
32
/// <summary>
32
33
/// Determines whether the specified model is loaded
@@ -35,7 +36,7 @@ public interface IStableDiffusionService
35
36
/// <returns>
36
37
/// <c>true</c> if the specified model is loaded; otherwise, <c>false</c>.
37
38
/// </returns>
38
- bool IsModelLoaded ( StableDiffusionModelSet model ) ;
39
+ bool IsModelLoaded ( IOnnxModel model ) ;
39
40
40
41
/// <summary>
41
42
/// Generates the StableDiffusion image using the prompt and options provided.
@@ -45,7 +46,7 @@ public interface IStableDiffusionService
45
46
/// <param name="progressCallback">The callback used to provide progess of the current InferenceSteps.</param>
46
47
/// <param name="cancellationToken">The cancellation token.</param>
47
48
/// <returns>The diffusion result as <see cref="DenseTensor<float>"/></returns>
48
- Task < DenseTensor < float > > GenerateAsync ( StableDiffusionModelSet model , PromptOptions prompt , SchedulerOptions options , Action < DiffusionProgress > progressCallback = null , CancellationToken cancellationToken = default ) ;
49
+ Task < DenseTensor < float > > GenerateAsync ( ModelOptions model , PromptOptions prompt , SchedulerOptions options , Action < DiffusionProgress > progressCallback = null , CancellationToken cancellationToken = default ) ;
49
50
50
51
/// <summary>
51
52
/// Generates the StableDiffusion image using the prompt and options provided.
@@ -55,7 +56,7 @@ public interface IStableDiffusionService
55
56
/// <param name="progressCallback">The callback used to provide progess of the current InferenceSteps.</param>
56
57
/// <param name="cancellationToken">The cancellation token.</param>
57
58
/// <returns>The diffusion result as <see cref="SixLabors.ImageSharp.Image<Rgba32>"/></returns>
58
- Task < Image < Rgba32 > > GenerateAsImageAsync ( StableDiffusionModelSet model , PromptOptions prompt , SchedulerOptions options , Action < DiffusionProgress > progressCallback = null , CancellationToken cancellationToken = default ) ;
59
+ Task < Image < Rgba32 > > GenerateAsImageAsync ( ModelOptions model , PromptOptions prompt , SchedulerOptions options , Action < DiffusionProgress > progressCallback = null , CancellationToken cancellationToken = default ) ;
59
60
60
61
/// <summary>
61
62
/// Generates the StableDiffusion image using the prompt and options provided.
@@ -65,7 +66,7 @@ public interface IStableDiffusionService
65
66
/// <param name="progressCallback">The callback used to provide progess of the current InferenceSteps.</param>
66
67
/// <param name="cancellationToken">The cancellation token.</param>
67
68
/// <returns>The diffusion result as <see cref="byte[]"/></returns>
68
- Task < byte [ ] > GenerateAsBytesAsync ( StableDiffusionModelSet model , PromptOptions prompt , SchedulerOptions options , Action < DiffusionProgress > progressCallback = null , CancellationToken cancellationToken = default ) ;
69
+ Task < byte [ ] > GenerateAsBytesAsync ( ModelOptions model , PromptOptions prompt , SchedulerOptions options , Action < DiffusionProgress > progressCallback = null , CancellationToken cancellationToken = default ) ;
69
70
70
71
/// <summary>
71
72
/// Generates the StableDiffusion image using the prompt and options provided.
@@ -75,7 +76,7 @@ public interface IStableDiffusionService
75
76
/// <param name="progressCallback">The callback used to provide progess of the current InferenceSteps.</param>
76
77
/// <param name="cancellationToken">The cancellation token.</param>
77
78
/// <returns>The diffusion result as <see cref="System.IO.Stream"/></returns>
78
- Task < Stream > GenerateAsStreamAsync ( StableDiffusionModelSet model , PromptOptions prompt , SchedulerOptions options , Action < DiffusionProgress > progressCallback = null , CancellationToken cancellationToken = default ) ;
79
+ Task < Stream > GenerateAsStreamAsync ( ModelOptions model , PromptOptions prompt , SchedulerOptions options , Action < DiffusionProgress > progressCallback = null , CancellationToken cancellationToken = default ) ;
79
80
80
81
/// <summary>
81
82
/// Generates a batch of StableDiffusion image using the prompt and options provided.
@@ -87,7 +88,7 @@ public interface IStableDiffusionService
87
88
/// <param name="progressCallback">The progress callback.</param>
88
89
/// <param name="cancellationToken">The cancellation token.</param>
89
90
/// <returns></returns>
90
- IAsyncEnumerable < BatchResult > GenerateBatchAsync ( StableDiffusionModelSet model , PromptOptions promptOptions , SchedulerOptions schedulerOptions , BatchOptions batchOptions , Action < DiffusionProgress > progressCallback = null , CancellationToken cancellationToken = default ) ;
91
+ IAsyncEnumerable < BatchResult > GenerateBatchAsync ( ModelOptions model , PromptOptions promptOptions , SchedulerOptions schedulerOptions , BatchOptions batchOptions , Action < DiffusionProgress > progressCallback = null , CancellationToken cancellationToken = default ) ;
91
92
92
93
/// <summary>
93
94
/// Generates a batch of StableDiffusion image using the prompt and options provided.
@@ -99,7 +100,7 @@ public interface IStableDiffusionService
99
100
/// <param name="progressCallback">The progress callback.</param>
100
101
/// <param name="cancellationToken">The cancellation token.</param>
101
102
/// <returns></returns>
102
- IAsyncEnumerable < Image < Rgba32 > > GenerateBatchAsImageAsync ( StableDiffusionModelSet model , PromptOptions promptOptions , SchedulerOptions schedulerOptions , BatchOptions batchOptions , Action < DiffusionProgress > progressCallback = null , CancellationToken cancellationToken = default ) ;
103
+ IAsyncEnumerable < Image < Rgba32 > > GenerateBatchAsImageAsync ( ModelOptions model , PromptOptions promptOptions , SchedulerOptions schedulerOptions , BatchOptions batchOptions , Action < DiffusionProgress > progressCallback = null , CancellationToken cancellationToken = default ) ;
103
104
104
105
/// <summary>
105
106
/// Generates a batch of StableDiffusion image using the prompt and options provided.
@@ -111,7 +112,7 @@ public interface IStableDiffusionService
111
112
/// <param name="progressCallback">The progress callback.</param>
112
113
/// <param name="cancellationToken">The cancellation token.</param>
113
114
/// <returns></returns>
114
- IAsyncEnumerable < byte [ ] > GenerateBatchAsBytesAsync ( StableDiffusionModelSet model , PromptOptions promptOptions , SchedulerOptions schedulerOptions , BatchOptions batchOptions , Action < DiffusionProgress > progressCallback = null , CancellationToken cancellationToken = default ) ;
115
+ IAsyncEnumerable < byte [ ] > GenerateBatchAsBytesAsync ( ModelOptions model , PromptOptions promptOptions , SchedulerOptions schedulerOptions , BatchOptions batchOptions , Action < DiffusionProgress > progressCallback = null , CancellationToken cancellationToken = default ) ;
115
116
116
117
/// <summary>
117
118
/// Generates a batch of StableDiffusion image using the prompt and options provided.
@@ -123,6 +124,6 @@ public interface IStableDiffusionService
123
124
/// <param name="progressCallback">The progress callback.</param>
124
125
/// <param name="cancellationToken">The cancellation token.</param>
125
126
/// <returns></returns>
126
- IAsyncEnumerable < Stream > GenerateBatchAsStreamAsync ( StableDiffusionModelSet model , PromptOptions promptOptions , SchedulerOptions schedulerOptions , BatchOptions batchOptions , Action < DiffusionProgress > progressCallback = null , CancellationToken cancellationToken = default ) ;
127
+ IAsyncEnumerable < Stream > GenerateBatchAsStreamAsync ( ModelOptions model , PromptOptions promptOptions , SchedulerOptions schedulerOptions , BatchOptions batchOptions , Action < DiffusionProgress > progressCallback = null , CancellationToken cancellationToken = default ) ;
127
128
}
128
129
}
0 commit comments