This repository was archived by the owner on Nov 27, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
OnnxStack.StableDiffusion Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 11using Microsoft . Extensions . DependencyInjection ;
22using OnnxStack . StableDiffusion . Common ;
33using OnnxStack . StableDiffusion . Services ;
4+ using SixLabors . ImageSharp ;
5+ using SixLabors . ImageSharp . Memory ;
46
57namespace OnnxStack . Core
68{
@@ -15,10 +17,25 @@ public static class Registration
1517 /// <param name="serviceCollection">The service collection.</param>
1618 public static void AddOnnxStackStableDiffusion ( this IServiceCollection serviceCollection )
1719 {
20+ ConfigureLibraries ( ) ;
1821 serviceCollection . AddOnnxStack ( ) ;
1922 serviceCollection . AddSingleton < IPromptService , PromptService > ( ) ;
2023 serviceCollection . AddSingleton < ISchedulerService , SchedulerService > ( ) ;
2124 serviceCollection . AddSingleton < IStableDiffusionService , StableDiffusionService > ( ) ;
2225 }
26+
27+
28+ /// <summary>
29+ /// Configures any 3rd party libraries.
30+ /// </summary>
31+ private static void ConfigureLibraries ( )
32+ {
33+ // Create a 100MB image buffer pool
34+ Configuration . Default . PreferContiguousImageBuffers = true ;
35+ Configuration . Default . MemoryAllocator = MemoryAllocator . Create ( new MemoryAllocatorOptions
36+ {
37+ MaximumPoolSizeMegabytes = 100 ,
38+ } ) ;
39+ }
2340 }
2441}
You can’t perform that action at this time.
0 commit comments