Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

Commit 4134ece

Browse files
committed
Support default and controlnet Unet in pipeline
1 parent 6938b70 commit 4134ece

14 files changed

+182
-80
lines changed

OnnxStack.Console/Examples/ControlNetExample.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ public async Task RunAsync()
3535
var controlImage = await OnnxImage.FromFileAsync("D:\\Repositories\\OnnxStack\\Assets\\Samples\\OpenPose.png");
3636

3737
// Create ControlNet
38-
var controlNet = ControlNetModel.Create("D:\\Repositories\\controlnet_onnx\\controlnet\\openpose.onnx", ControlNetType.OpenPose, DiffuserPipelineType.StableDiffusion);
38+
var controlNet = ControlNetModel.Create("D:\\Models\\controlnet_onnx\\controlnet\\openpose.onnx", ControlNetType.OpenPose, DiffuserPipelineType.StableDiffusion);
3939

4040
// Create Pipeline
41-
var pipeline = StableDiffusionPipeline.CreatePipeline("D:\\Repositories\\stable_diffusion_onnx", ModelType.ControlNet);
41+
var pipeline = StableDiffusionPipeline.CreatePipeline("D:\\Models\\stable-diffusion-v1-5-onnx");
4242

4343
// Prompt
4444
var promptOptions = new PromptOptions
@@ -48,7 +48,8 @@ public async Task RunAsync()
4848
InputContolImage = controlImage
4949
};
5050

51-
51+
// Preload (optional)
52+
await pipeline.LoadAsync(true);
5253

5354
// Run pipeline
5455
var result = await pipeline.RunAsync(promptOptions, controlNet: controlNet, progressCallback: OutputHelpers.ProgressCallback);

OnnxStack.Console/Examples/ControlNetFeatureExample.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using OnnxStack.StableDiffusion.Enums;
55
using OnnxStack.StableDiffusion.Models;
66
using OnnxStack.StableDiffusion.Pipelines;
7-
using SixLabors.ImageSharp;
87

98
namespace OnnxStack.Console.Runner
109
{
@@ -35,7 +34,7 @@ public async Task RunAsync()
3534
var inputImage = await OnnxImage.FromFileAsync("D:\\Repositories\\OnnxStack\\Assets\\Samples\\Img2Img_Start.bmp");
3635

3736
// Create Annotation pipeline
38-
var annotationPipeline = FeatureExtractorPipeline.CreatePipeline("D:\\Repositories\\controlnet_onnx\\annotators\\depth.onnx", sampleSize: 512, normalizeOutput: true);
37+
var annotationPipeline = FeatureExtractorPipeline.CreatePipeline("D:\\Models\\controlnet_onnx\\annotators\\depth.onnx", sampleSize: 512, normalizeOutput: true);
3938

4039
// Create Depth Image
4140
var controlImage = await annotationPipeline.RunAsync(inputImage);
@@ -44,10 +43,10 @@ public async Task RunAsync()
4443
await controlImage.SaveAsync(Path.Combine(_outputDirectory, $"Depth.png"));
4544

4645
// Create ControlNet
47-
var controlNet = ControlNetModel.Create("D:\\Repositories\\controlnet_onnx\\controlnet\\depth.onnx", ControlNetType.Depth, DiffuserPipelineType.StableDiffusion);
46+
var controlNet = ControlNetModel.Create("D:\\Models\\controlnet_onnx\\controlnet\\depth.onnx", ControlNetType.Depth, DiffuserPipelineType.StableDiffusion);
4847

4948
// Create Pipeline
50-
var pipeline = StableDiffusionPipeline.CreatePipeline("D:\\Repositories\\stable_diffusion_onnx", ModelType.ControlNet);
49+
var pipeline = StableDiffusionPipeline.CreatePipeline("D:\\Models\\stable-diffusion-v1-5-onnx");
5150

5251
// Prompt
5352
var promptOptions = new PromptOptions
@@ -57,6 +56,9 @@ public async Task RunAsync()
5756
InputContolImage = controlImage
5857
};
5958

59+
// Preload (optional)
60+
await pipeline.LoadAsync(true);
61+
6062
// Run pipeline
6163
var result = await pipeline.RunAsync(promptOptions, controlNet: controlNet, progressCallback: OutputHelpers.ProgressCallback);
6264

OnnxStack.Console/appsettings.json

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,26 @@
3232
"BlankTokenId": 49407,
3333
"TokenizerLimit": 77,
3434
"TokenizerLength": 768,
35-
"OnnxModelPath": "D:\\Repositories\\stable-diffusion-v1-5-onnx\\cliptokenizer.onnx"
35+
"OnnxModelPath": "D:\\Models\\stable-diffusion-v1-5-onnx\\cliptokenizer.onnx"
3636
},
3737
"TextEncoderConfig": {
38-
"OnnxModelPath": "D:\\Repositories\\stable-diffusion-v1-5-onnx\\text_encoder\\model.onnx"
38+
"OnnxModelPath": "D:\\Models\\stable-diffusion-v1-5-onnx\\text_encoder\\model.onnx"
3939
},
4040
"UnetConfig": {
4141
"ModelType": "Base",
42-
"OnnxModelPath": "D:\\Repositories\\stable-diffusion-v1-5-onnx\\unet\\model.onnx"
42+
"OnnxModelPath": "D:\\Models\\stable-diffusion-v1-5-onnx\\unet\\model.onnx"
4343
},
4444
"VaeDecoderConfig": {
4545
"ScaleFactor": 0.18215,
46-
"OnnxModelPath": "D:\\Repositories\\stable-diffusion-v1-5-onnx\\vae_decoder\\model.onnx"
46+
"OnnxModelPath": "D:\\Models\\stable-diffusion-v1-5-onnx\\vae_decoder\\model.onnx"
4747
},
4848
"VaeEncoderConfig": {
4949
"ScaleFactor": 0.18215,
50-
"OnnxModelPath": "D:\\Repositories\\stable-diffusion-v1-5-onnx\\vae_encoder\\model.onnx"
50+
"OnnxModelPath": "D:\\Models\\stable-diffusion-v1-5-onnx\\vae_encoder\\model.onnx"
51+
},
52+
"ControlNetConfig": {
53+
"ModelType": "ControlNet",
54+
"OnnxModelPath": "D:\\Models\\stable-diffusion-v1-5-onnx\\controlnet\\model.onnx"
5155
}
5256
},
5357
{
@@ -70,22 +74,26 @@
7074
"BlankTokenId": 49407,
7175
"TokenizerLimit": 77,
7276
"TokenizerLength": 768,
73-
"OnnxModelPath": "D:\\Repositories\\LCM_Dreamshaper_v7-onnx\\tokenizer\\model.onnx"
77+
"OnnxModelPath": "D:\\Models\\LCM_Dreamshaper_v7-onnx\\tokenizer\\model.onnx"
7478
},
7579
"TextEncoderConfig": {
76-
"OnnxModelPath": "D:\\Repositories\\LCM_Dreamshaper_v7-onnx\\text_encoder\\model.onnx"
80+
"OnnxModelPath": "D:\\Models\\LCM_Dreamshaper_v7-onnx\\text_encoder\\model.onnx"
7781
},
7882
"UnetConfig": {
7983
"ModelType": "Base",
80-
"OnnxModelPath": "D:\\Repositories\\LCM_Dreamshaper_v7-onnx\\unet\\model.onnx"
84+
"OnnxModelPath": "D:\\Models\\LCM_Dreamshaper_v7-onnx\\unet\\model.onnx"
8185
},
8286
"VaeDecoderConfig": {
8387
"ScaleFactor": 0.18215,
84-
"OnnxModelPath": "D:\\Repositories\\LCM_Dreamshaper_v7-onnx\\vae_decoder\\model.onnx"
88+
"OnnxModelPath": "D:\\Models\\LCM_Dreamshaper_v7-onnx\\vae_decoder\\model.onnx"
8589
},
8690
"VaeEncoderConfig": {
8791
"ScaleFactor": 0.18215,
88-
"OnnxModelPath": "D:\\Repositories\\LCM_Dreamshaper_v7-onnx\\vae_encoder\\model.onnx"
92+
"OnnxModelPath": "D:\\Models\\LCM_Dreamshaper_v7-onnx\\vae_encoder\\model.onnx"
93+
},
94+
"ControlNetConfig": {
95+
"ModelType": "ControlNet",
96+
"OnnxModelPath": "D:\\Models\\LCM_Dreamshaper_v7-onnx\\controlnet\\model.onnx"
8997
}
9098
},
9199
{
@@ -108,32 +116,32 @@
108116
"BlankTokenId": 49407,
109117
"TokenizerLimit": 77,
110118
"TokenizerLength": 768,
111-
"OnnxModelPath": "D:\\Repositories\\stable-diffusion-xl-base-1.0-onnx\\tokenizer\\model.onnx"
119+
"OnnxModelPath": "D:\\Models\\stable-diffusion-xl-base-1.0-onnx\\tokenizer\\model.onnx"
112120
},
113121
"Tokenizer2Config": {
114122
"PadTokenId": 1,
115123
"BlankTokenId": 49407,
116124
"TokenizerLimit": 77,
117125
"TokenizerLength": 1280,
118-
"OnnxModelPath": "D:\\Repositories\\stable-diffusion-xl-base-1.0-onnx\\tokenizer_2\\model.onnx"
126+
"OnnxModelPath": "D:\\Models\\stable-diffusion-xl-base-1.0-onnx\\tokenizer_2\\model.onnx"
119127
},
120128
"TextEncoderConfig": {
121-
"OnnxModelPath": "D:\\Repositories\\stable-diffusion-xl-base-1.0-onnx\\text_encoder\\model.onnx"
129+
"OnnxModelPath": "D:\\Models\\stable-diffusion-xl-base-1.0-onnx\\text_encoder\\model.onnx"
122130
},
123131
"TextEncoder2Config": {
124-
"OnnxModelPath": "D:\\Repositories\\stable-diffusion-xl-base-1.0-onnx\\text_encoder_2\\model.onnx"
132+
"OnnxModelPath": "D:\\Models\\stable-diffusion-xl-base-1.0-onnx\\text_encoder_2\\model.onnx"
125133
},
126134
"UnetConfig": {
127135
"ModelType": "Base",
128-
"OnnxModelPath": "D:\\Repositories\\stable-diffusion-xl-base-1.0-onnx\\unet\\model.onnx"
136+
"OnnxModelPath": "D:\\Models\\stable-diffusion-xl-base-1.0-onnx\\unet\\model.onnx"
129137
},
130138
"VaeDecoderConfig": {
131139
"ScaleFactor": 0.13025,
132-
"OnnxModelPath": "D:\\Repositories\\stable-diffusion-xl-base-1.0-onnx\\vae_decoder\\model.onnx"
140+
"OnnxModelPath": "D:\\Models\\stable-diffusion-xl-base-1.0-onnx\\vae_decoder\\model.onnx"
133141
},
134142
"VaeEncoderConfig": {
135143
"ScaleFactor": 0.13025,
136-
"OnnxModelPath": "D:\\Repositories\\stable-diffusion-xl-base-1.0-onnx\\vae_encoder\\model.onnx"
144+
"OnnxModelPath": "D:\\Models\\stable-diffusion-xl-base-1.0-onnx\\vae_encoder\\model.onnx"
137145
}
138146
}
139147
]

OnnxStack.StableDiffusion/Config/StableDiffusionModelSet.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public record StableDiffusionModelSet : IOnnxModelSetConfig
3636

3737
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
3838
public UNetConditionModelConfig UnetConfig { get; set; }
39+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
40+
public UNetConditionModelConfig Unet2Config { get; set; }
3941

4042
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
4143
public AutoEncoderModelConfig VaeDecoderConfig { get; set; }
@@ -44,11 +46,9 @@ public record StableDiffusionModelSet : IOnnxModelSetConfig
4446
public AutoEncoderModelConfig VaeEncoderConfig { get; set; }
4547

4648
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
47-
public UNetConditionModelConfig DecoderUnetConfig { get; set; }
49+
public UNetConditionModelConfig ControlNetUnetConfig { get; set; }
4850

4951
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
5052
public SchedulerOptions SchedulerOptions { get; set; }
51-
52-
5353
}
5454
}

OnnxStack.StableDiffusion/Enums/ModelType.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ public enum ModelType
44
{
55
Base = 0,
66
Refiner = 1,
7-
ControlNet = 2,
87
Turbo = 3,
98
Inpaint = 4
109
}

OnnxStack.StableDiffusion/Helpers/ModelFactory.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,9 @@ public static StableDiffusionModelSet CreateModelSet(string modelFolder, Diffuse
3737
var vaeEncoderPath = Path.Combine(modelFolder, "vae_encoder", "model.onnx");
3838
var controlNetPath = Path.Combine(modelFolder, "controlNet", "model.onnx");
3939

40-
// Some repositories have the ControlNet in the unet folder, some in the controlnet folder
41-
if (modelType == ModelType.ControlNet && File.Exists(controlNetPath))
42-
unetPath = controlNetPath;
43-
4440
var diffusers = modelType switch
4541
{
4642
ModelType.Inpaint => new List<DiffuserType> { DiffuserType.ImageInpaint },
47-
ModelType.ControlNet => new List<DiffuserType> { DiffuserType.ControlNet, DiffuserType.ControlNetImage },
4843
_ => new List<DiffuserType> { DiffuserType.TextToImage, DiffuserType.ImageToImage, DiffuserType.ImageInpaintLegacy }
4944
};
5045

@@ -79,6 +74,19 @@ public static StableDiffusionModelSet CreateModelSet(string modelFolder, Diffuse
7974
OnnxModelPath = vaeEncoderPath
8075
};
8176

77+
var contronNetConfig = default(UNetConditionModelConfig);
78+
if (File.Exists(controlNetPath))
79+
{
80+
diffusers.Add(DiffuserType.ControlNet);
81+
diffusers.Add(DiffuserType.ControlNetImage);
82+
contronNetConfig = new UNetConditionModelConfig
83+
{
84+
ModelType = modelType,
85+
OnnxModelPath = controlNetPath
86+
};
87+
}
88+
89+
8290
// SDXL Pipelines
8391
if (pipeline == DiffuserPipelineType.StableDiffusionXL || pipeline == DiffuserPipelineType.LatentConsistencyXL)
8492
{
@@ -129,7 +137,8 @@ public static StableDiffusionModelSet CreateModelSet(string modelFolder, Diffuse
129137
TextEncoder2Config = textEncoder2Config,
130138
UnetConfig = unetConfig,
131139
VaeDecoderConfig = vaeDecoderConfig,
132-
VaeEncoderConfig = vaeEncoderConfig
140+
VaeEncoderConfig = vaeEncoderConfig,
141+
ControlNetUnetConfig = contronNetConfig
133142
};
134143
return configuration;
135144
}
@@ -201,7 +210,7 @@ public static StableDiffusionModelSet CreateStableCascadeModelSet(string modelFo
201210
TextEncoderConfig = textEncoderConfig,
202211
TextEncoder2Config = textEncoder2Config,
203212
UnetConfig = priorUnetConfig,
204-
DecoderUnetConfig = decoderUnetConfig,
213+
Unet2Config = decoderUnetConfig,
205214
VaeDecoderConfig = vqganConfig,
206215
VaeEncoderConfig = imageEncoderConfig
207216
};

OnnxStack.StableDiffusion/Pipelines/Base/IPipeline.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public interface IPipeline
4343
/// Loads the pipeline.
4444
/// </summary>
4545
/// <returns></returns>
46-
Task LoadAsync();
46+
Task LoadAsync(bool controlNet = false);
4747

4848

4949
/// <summary>

OnnxStack.StableDiffusion/Pipelines/Base/PipelineBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected PipelineBase(PipelineOptions pipelineOptions, ILogger logger)
6666
/// Loads the pipeline.
6767
/// </summary>
6868
/// <returns></returns>
69-
public abstract Task LoadAsync();
69+
public abstract Task LoadAsync(bool controlNet = false);
7070

7171

7272
/// <summary>

OnnxStack.StableDiffusion/Pipelines/InstaFlowPipeline.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public sealed class InstaFlowPipeline : StableDiffusionPipeline
2525
/// <param name="vaeDecoder">The vae decoder.</param>
2626
/// <param name="vaeEncoder">The vae encoder.</param>
2727
/// <param name="logger">The logger.</param>
28-
public InstaFlowPipeline(PipelineOptions pipelineOptions, TokenizerModel tokenizer, TextEncoderModel textEncoder, UNetConditionModel unet, AutoEncoderModel vaeDecoder, AutoEncoderModel vaeEncoder, List<DiffuserType> diffusers, SchedulerOptions defaultSchedulerOptions = default, ILogger logger = default)
29-
: base(pipelineOptions, tokenizer, textEncoder, unet, vaeDecoder, vaeEncoder, diffusers, defaultSchedulerOptions, logger)
28+
public InstaFlowPipeline(PipelineOptions pipelineOptions, TokenizerModel tokenizer, TextEncoderModel textEncoder, UNetConditionModel unet, AutoEncoderModel vaeDecoder, AutoEncoderModel vaeEncoder, UNetConditionModel controlNet, List<DiffuserType> diffusers, SchedulerOptions defaultSchedulerOptions = default, ILogger logger = default)
29+
: base(pipelineOptions, tokenizer, textEncoder, unet, vaeDecoder, vaeEncoder, controlNet, diffusers, defaultSchedulerOptions, logger)
3030
{
3131
_supportedDiffusers = diffusers ?? new List<DiffuserType>
3232
{
@@ -62,7 +62,7 @@ protected override IDiffuser CreateDiffuser(DiffuserType diffuserType, ControlNe
6262
return diffuserType switch
6363
{
6464
DiffuserType.TextToImage => new TextDiffuser(_unet, _vaeDecoder, _vaeEncoder, _pipelineOptions.MemoryMode, _logger),
65-
DiffuserType.ControlNet => new ControlNetDiffuser(controlNetModel, _unet, _vaeDecoder, _vaeEncoder, _pipelineOptions.MemoryMode, _logger),
65+
DiffuserType.ControlNet => new ControlNetDiffuser(controlNetModel, _controlNetUnet, _vaeDecoder, _vaeEncoder, _pipelineOptions.MemoryMode, _logger),
6666
_ => throw new NotImplementedException()
6767
};
6868
}
@@ -81,8 +81,12 @@ protected override IDiffuser CreateDiffuser(DiffuserType diffuserType, ControlNe
8181
var textEncoder = new TextEncoderModel(modelSet.TextEncoderConfig.ApplyDefaults(modelSet));
8282
var vaeDecoder = new AutoEncoderModel(modelSet.VaeDecoderConfig.ApplyDefaults(modelSet));
8383
var vaeEncoder = new AutoEncoderModel(modelSet.VaeEncoderConfig.ApplyDefaults(modelSet));
84+
var controlnet = default(UNetConditionModel);
85+
if (modelSet.ControlNetUnetConfig is not null)
86+
controlnet = new UNetConditionModel(modelSet.ControlNetUnetConfig.ApplyDefaults(modelSet));
87+
8488
var pipelineOptions = new PipelineOptions(modelSet.Name, modelSet.MemoryMode);
85-
return new InstaFlowPipeline(pipelineOptions, tokenizer, textEncoder, unet, vaeDecoder, vaeEncoder, modelSet.Diffusers, modelSet.SchedulerOptions, logger);
89+
return new InstaFlowPipeline(pipelineOptions, tokenizer, textEncoder, unet, vaeDecoder, vaeEncoder, controlnet, modelSet.Diffusers, modelSet.SchedulerOptions, logger);
8690
}
8791

8892

OnnxStack.StableDiffusion/Pipelines/LatentConsistencyPipeline.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public sealed class LatentConsistencyPipeline : StableDiffusionPipeline
3030
/// <param name="vaeDecoder">The vae decoder.</param>
3131
/// <param name="vaeEncoder">The vae encoder.</param>
3232
/// <param name="logger">The logger.</param>
33-
public LatentConsistencyPipeline(PipelineOptions pipelineOptions, TokenizerModel tokenizer, TextEncoderModel textEncoder, UNetConditionModel unet, AutoEncoderModel vaeDecoder, AutoEncoderModel vaeEncoder, List<DiffuserType> diffusers, SchedulerOptions defaultSchedulerOptions = default, ILogger logger = default)
34-
: base(pipelineOptions, tokenizer, textEncoder, unet, vaeDecoder, vaeEncoder, diffusers, defaultSchedulerOptions, logger)
33+
public LatentConsistencyPipeline(PipelineOptions pipelineOptions, TokenizerModel tokenizer, TextEncoderModel textEncoder, UNetConditionModel unet, AutoEncoderModel vaeDecoder, AutoEncoderModel vaeEncoder, UNetConditionModel controlNet, List<DiffuserType> diffusers, SchedulerOptions defaultSchedulerOptions = default, ILogger logger = default)
34+
: base(pipelineOptions, tokenizer, textEncoder, unet, vaeDecoder, vaeEncoder, controlNet, diffusers, defaultSchedulerOptions, logger)
3535
{
3636
_supportedSchedulers = new List<SchedulerType>
3737
{
@@ -112,8 +112,8 @@ protected override IDiffuser CreateDiffuser(DiffuserType diffuserType, ControlNe
112112
DiffuserType.TextToImage => new TextDiffuser(_unet, _vaeDecoder, _vaeEncoder, _pipelineOptions.MemoryMode, _logger),
113113
DiffuserType.ImageToImage => new ImageDiffuser(_unet, _vaeDecoder, _vaeEncoder, _pipelineOptions.MemoryMode, _logger),
114114
DiffuserType.ImageInpaintLegacy => new InpaintLegacyDiffuser(_unet, _vaeDecoder, _vaeEncoder, _pipelineOptions.MemoryMode, _logger),
115-
DiffuserType.ControlNet => new ControlNetDiffuser(controlNetModel, _unet, _vaeDecoder, _vaeEncoder, _pipelineOptions.MemoryMode, _logger),
116-
DiffuserType.ControlNetImage => new ControlNetImageDiffuser(controlNetModel, _unet, _vaeDecoder, _vaeEncoder, _pipelineOptions.MemoryMode, _logger),
115+
DiffuserType.ControlNet => new ControlNetDiffuser(controlNetModel, _controlNetUnet, _vaeDecoder, _vaeEncoder, _pipelineOptions.MemoryMode, _logger),
116+
DiffuserType.ControlNetImage => new ControlNetImageDiffuser(controlNetModel, _controlNetUnet, _vaeDecoder, _vaeEncoder, _pipelineOptions.MemoryMode, _logger),
117117
_ => throw new NotImplementedException()
118118
};
119119
}
@@ -132,8 +132,12 @@ protected override IDiffuser CreateDiffuser(DiffuserType diffuserType, ControlNe
132132
var textEncoder = new TextEncoderModel(modelSet.TextEncoderConfig.ApplyDefaults(modelSet));
133133
var vaeDecoder = new AutoEncoderModel(modelSet.VaeDecoderConfig.ApplyDefaults(modelSet));
134134
var vaeEncoder = new AutoEncoderModel(modelSet.VaeEncoderConfig.ApplyDefaults(modelSet));
135+
var controlnet = default(UNetConditionModel);
136+
if (modelSet.ControlNetUnetConfig is not null)
137+
controlnet = new UNetConditionModel(modelSet.ControlNetUnetConfig.ApplyDefaults(modelSet));
138+
135139
var pipelineOptions = new PipelineOptions(modelSet.Name, modelSet.MemoryMode);
136-
return new LatentConsistencyPipeline(pipelineOptions, tokenizer, textEncoder, unet, vaeDecoder, vaeEncoder, modelSet.Diffusers, modelSet.SchedulerOptions, logger);
140+
return new LatentConsistencyPipeline(pipelineOptions, tokenizer, textEncoder, unet, vaeDecoder, vaeEncoder, controlnet, modelSet.Diffusers, modelSet.SchedulerOptions, logger);
137141
}
138142

139143

0 commit comments

Comments
 (0)