@@ -53,11 +53,10 @@ var pipeline = StableDiffusionPipeline.CreatePipeline("models\\stable-diffusion-
53
53
var promptOptions = new PromptOptions { Prompt = " Photo of a cute dog." };
54
54
55
55
// Run Pipleine
56
- var result = await pipeline .RunAsync (promptOptions );
56
+ var result = await pipeline .GenerateImageAsync (promptOptions );
57
57
58
58
// Save image result
59
- var image = result .ToImage ();
60
- await image .SaveAsPngAsync (" D:\\ Results\\ Image.png" );
59
+ await result .SaveAsync (" D:\\ Results\\ Image.png" );
61
60
62
61
// Unload Pipleine
63
62
await pipeline .UnloadAsync ();
@@ -86,8 +85,8 @@ var batchOptions = new BatchOptions
86
85
await foreach (var result in pipeline .RunBatchAsync (batchOptions , promptOptions ))
87
86
{
88
87
// Save Image result
89
- var image = result .ImageResult . ToImage ( );
90
- await image .SaveAsPngAsync ($" Output_Batch_{result .SchedulerOptions .Seed }.png" );
88
+ var image = new OnnxImage ( result .ImageResult );
89
+ await image .SaveAsync ($" Output_Batch_{result .SchedulerOptions .Seed }.png" );
91
90
}
92
91
93
92
// Unload Pipleine
@@ -107,7 +106,7 @@ Run Stable Diffusion process with an initial image as input
107
106
var pipeline = StableDiffusionPipeline .CreatePipeline (" models\\ stable-diffusion-v1-5" );
108
107
109
108
// Load Input Image
110
- var inputImage = await InputImage .FromFileAsync (" Input.png" );
109
+ var inputImage = await OnnxImage .FromFileAsync (" Input.png" );
111
110
112
111
// Set Prompt Options
113
112
var promptOptions = new PromptOptions
@@ -125,11 +124,10 @@ var schedulerOptions = pipeline.DefaultSchedulerOptions with
125
124
};
126
125
127
126
// Run Pipleine
128
- var result = await pipeline .RunAsync (promptOptions , schedulerOptions );
127
+ var result = await pipeline .GenerateImageAsync (promptOptions , schedulerOptions );
129
128
130
129
// Save image result
131
- var image = result .ToImage ();
132
- await image .SaveAsPngAsync (" Output_ImageToImage.png" );
130
+ await result .SaveAsync (" Output_ImageToImage.png" );
133
131
134
132
// Unload Pipleine
135
133
await pipeline .UnloadAsync ();
@@ -153,7 +151,7 @@ var pipeline = StableDiffusionPipeline.CreatePipeline("models\\stable_diffusion_
153
151
var controlNet = ControlNetModel .Create (" models\\ controlnet_onnx\\ controlnet\\ depth.onnx" );
154
152
155
153
// Load Control Image
156
- var controlImage = await InputImage .FromFileAsync (" Input_Depth.png" );
154
+ var controlImage = await OnnxImage .FromFileAsync (" Input_Depth.png" );
157
155
158
156
// Set Prompt Options
159
157
var promptOptions = new PromptOptions
@@ -164,11 +162,10 @@ var promptOptions = new PromptOptions
164
162
};
165
163
166
164
// Run Pipleine
167
- var result = await pipeline .RunAsync (promptOptions , controlNet : controlNet );
165
+ var result = await pipeline .GenerateImageAsync (promptOptions , controlNet : controlNet );
168
166
169
167
// Save image result
170
- var image = result .ToImage ();
171
- await image .SaveAsPngAsync (" Output_ControlNet.png" );
168
+ await result .SaveAsync (" Output_ControlNet.png" );
172
169
173
170
// Unload Pipleine
174
171
await pipeline .UnloadAsync ();
@@ -194,7 +191,7 @@ var pipeline = StableDiffusionPipeline.CreatePipeline("models\\stable-diffusion-
194
191
195
192
// Load Video
196
193
var targetFPS = 15 ;
197
- var videoInput = await VideoInput .FromFileAsync (" Input.gif" , targetFPS );
194
+ var videoInput = await OnnxVideo .FromFileAsync (" Input.gif" , targetFPS );
198
195
199
196
// Add text and video to prompt
200
197
var promptOptions = new PromptOptions
@@ -205,11 +202,10 @@ var pipeline = StableDiffusionPipeline.CreatePipeline("models\\stable-diffusion-
205
202
};
206
203
207
204
// Run pipeline
208
- var result = await pipeline .RunAsync (promptOptions , progressCallback : OutputHelpers . FrameProgressCallback );
205
+ var result = await pipeline .GenerateVideoAsync (promptOptions );
209
206
210
207
// Save Video File
211
- var outputFilename = Path .Combine (_outputDirectory , " Output_VideoToVideo.mp4" );
212
- await VideoInput .SaveFileAsync (result , outputFilename , targetFPS );
208
+ await result .SaveAsync (" Output_VideoToVideo.mp4" );
213
209
214
210
// Unload Pipleine
215
211
await pipeline .UnloadAsync ();
0 commit comments