@@ -53,11 +53,10 @@ var pipeline = StableDiffusionPipeline.CreatePipeline("models\\stable-diffusion-
5353var promptOptions = new PromptOptions { Prompt = " Photo of a cute dog." };
5454
5555// Run Pipleine
56- var result = await pipeline .RunAsync (promptOptions );
56+ var result = await pipeline .GenerateImageAsync (promptOptions );
5757
5858// Save image result
59- var image = result .ToImage ();
60- await image .SaveAsPngAsync (" D:\\ Results\\ Image.png" );
59+ await result .SaveAsync (" D:\\ Results\\ Image.png" );
6160
6261// Unload Pipleine
6362await pipeline .UnloadAsync ();
@@ -86,8 +85,8 @@ var batchOptions = new BatchOptions
8685await foreach (var result in pipeline .RunBatchAsync (batchOptions , promptOptions ))
8786{
8887 // 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" );
9190}
9291
9392// Unload Pipleine
@@ -107,7 +106,7 @@ Run Stable Diffusion process with an initial image as input
107106var pipeline = StableDiffusionPipeline .CreatePipeline (" models\\ stable-diffusion-v1-5" );
108107
109108// Load Input Image
110- var inputImage = await InputImage .FromFileAsync (" Input.png" );
109+ var inputImage = await OnnxImage .FromFileAsync (" Input.png" );
111110
112111// Set Prompt Options
113112var promptOptions = new PromptOptions
@@ -125,11 +124,10 @@ var schedulerOptions = pipeline.DefaultSchedulerOptions with
125124};
126125
127126// Run Pipleine
128- var result = await pipeline .RunAsync (promptOptions , schedulerOptions );
127+ var result = await pipeline .GenerateImageAsync (promptOptions , schedulerOptions );
129128
130129// Save image result
131- var image = result .ToImage ();
132- await image .SaveAsPngAsync (" Output_ImageToImage.png" );
130+ await result .SaveAsync (" Output_ImageToImage.png" );
133131
134132// Unload Pipleine
135133await pipeline .UnloadAsync ();
@@ -153,7 +151,7 @@ var pipeline = StableDiffusionPipeline.CreatePipeline("models\\stable_diffusion_
153151var controlNet = ControlNetModel .Create (" models\\ controlnet_onnx\\ controlnet\\ depth.onnx" );
154152
155153// Load Control Image
156- var controlImage = await InputImage .FromFileAsync (" Input_Depth.png" );
154+ var controlImage = await OnnxImage .FromFileAsync (" Input_Depth.png" );
157155
158156// Set Prompt Options
159157var promptOptions = new PromptOptions
@@ -164,11 +162,10 @@ var promptOptions = new PromptOptions
164162};
165163
166164// Run Pipleine
167- var result = await pipeline .RunAsync (promptOptions , controlNet : controlNet );
165+ var result = await pipeline .GenerateImageAsync (promptOptions , controlNet : controlNet );
168166
169167// Save image result
170- var image = result .ToImage ();
171- await image .SaveAsPngAsync (" Output_ControlNet.png" );
168+ await result .SaveAsync (" Output_ControlNet.png" );
172169
173170// Unload Pipleine
174171await pipeline .UnloadAsync ();
@@ -194,7 +191,7 @@ var pipeline = StableDiffusionPipeline.CreatePipeline("models\\stable-diffusion-
194191
195192 // Load Video
196193 var targetFPS = 15 ;
197- var videoInput = await VideoInput .FromFileAsync (" Input.gif" , targetFPS );
194+ var videoInput = await OnnxVideo .FromFileAsync (" Input.gif" , targetFPS );
198195
199196 // Add text and video to prompt
200197 var promptOptions = new PromptOptions
@@ -205,11 +202,10 @@ var pipeline = StableDiffusionPipeline.CreatePipeline("models\\stable-diffusion-
205202 };
206203
207204 // Run pipeline
208- var result = await pipeline .RunAsync (promptOptions , progressCallback : OutputHelpers . FrameProgressCallback );
205+ var result = await pipeline .GenerateVideoAsync (promptOptions );
209206
210207 // 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" );
213209
214210// Unload Pipleine
215211await pipeline .UnloadAsync ();
0 commit comments