11using Microsoft . ML . OnnxRuntime ;
22using OnnxStack . Core . Config ;
33using OnnxStack . Core . Model ;
4+ using OnnxStack . StableDiffusion . Enums ;
45
56namespace OnnxStack . StableDiffusion . Models
67{
78 public class ControlNetModel : OnnxModelSession
89 {
10+ private readonly ControlNetModelConfig _configuration ;
911 public ControlNetModel ( ControlNetModelConfig configuration )
10- : base ( configuration ) { }
12+ : base ( configuration )
13+ {
14+ _configuration = configuration ;
15+ }
16+
17+ public ControlNetType Type => _configuration . Type ;
18+ public DiffuserPipelineType PipelineType => _configuration . PipelineType ;
1119
1220 public static ControlNetModel Create ( ControlNetModelConfig configuration )
1321 {
1422 return new ControlNetModel ( configuration ) ;
1523 }
1624
17- public static ControlNetModel Create ( string modelFile , int deviceId = 0 , ExecutionProvider executionProvider = ExecutionProvider . DirectML )
25+ public static ControlNetModel Create ( string modelFile , ControlNetType type , DiffuserPipelineType pipeline , int deviceId = 0 , ExecutionProvider executionProvider = ExecutionProvider . DirectML )
1826 {
1927 var configuration = new ControlNetModelConfig
2028 {
@@ -23,11 +31,17 @@ public static ControlNetModel Create(string modelFile, int deviceId = 0, Executi
2331 ExecutionMode = ExecutionMode . ORT_SEQUENTIAL ,
2432 InterOpNumThreads = 0 ,
2533 IntraOpNumThreads = 0 ,
26- OnnxModelPath = modelFile
34+ OnnxModelPath = modelFile ,
35+ Type = type ,
36+ PipelineType = pipeline ,
2737 } ;
2838 return new ControlNetModel ( configuration ) ;
2939 }
3040 }
3141
32- public record ControlNetModelConfig : OnnxModelConfig ;
42+ public record ControlNetModelConfig : OnnxModelConfig
43+ {
44+ public ControlNetType Type { get ; set ; }
45+ public DiffuserPipelineType PipelineType { get ; set ; }
46+ }
3347}
0 commit comments