22using OnnxStack . StableDiffusion . Config ;
33using OnnxStack . StableDiffusion . Helpers ;
44using OnnxStack . StableDiffusion . Results ;
5+ using System ;
6+ using System . Threading ;
57using System . Threading . Tasks ;
68
79namespace OnnxStack . StableDiffusion . Services
@@ -25,6 +27,14 @@ public Task<ImageResult> TextToImage(PromptOptions prompt, SchedulerOptions opti
2527 return TextToImageInternal ( prompt , options ) ;
2628 }
2729
30+ public Task < ImageResult > TextToImage ( PromptOptions prompt , SchedulerOptions options , Action < int , int > progress = null , CancellationToken cancellationToken = default )
31+ {
32+ return TextToImageInternal ( prompt , options , progress , cancellationToken ) ;
33+ }
34+
35+
36+
37+
2838 public Task < ImageResult > TextToImageFile ( PromptOptions prompt , string outputFile )
2939 {
3040 return TextToImageFileInternal ( prompt , new SchedulerOptions ( ) , outputFile ) ;
@@ -35,16 +45,21 @@ public Task<ImageResult> TextToImageFile(PromptOptions prompt, SchedulerOptions
3545 return TextToImageFileInternal ( prompt , options , outputFile ) ;
3646 }
3747
48+ public Task < ImageResult > TextToImageFile ( PromptOptions prompt , SchedulerOptions options , string outputFile , Action < int , int > progress = null , CancellationToken cancellationToken = default )
49+ {
50+ return TextToImageFileInternal ( prompt , options , outputFile , progress , cancellationToken ) ;
51+ }
52+
3853
39- private async Task < ImageResult > TextToImageInternal ( PromptOptions prompt , SchedulerOptions options )
54+ private async Task < ImageResult > TextToImageInternal ( PromptOptions prompt , SchedulerOptions options , Action < int , int > progress = null , CancellationToken cancellationToken = default )
4055 {
41- var imageTensorData = await _schedulerService . RunAsync ( prompt , options ) . ConfigureAwait ( false ) ;
56+ var imageTensorData = await _schedulerService . RunAsync ( prompt , options , progress , cancellationToken ) . ConfigureAwait ( false ) ;
4257 return ImageHelpers . TensorToImage ( options , imageTensorData ) ;
4358 }
4459
45- private async Task < ImageResult > TextToImageFileInternal ( PromptOptions prompt , SchedulerOptions options , string outputFile )
60+ private async Task < ImageResult > TextToImageFileInternal ( PromptOptions prompt , SchedulerOptions options , string outputFile , Action < int , int > progress = null , CancellationToken cancellationToken = default )
4661 {
47- var result = await TextToImageInternal ( prompt , options ) ;
62+ var result = await TextToImageInternal ( prompt , options , progress , cancellationToken ) ;
4863 if ( result is null )
4964 return null ;
5065
0 commit comments