@@ -32,7 +32,8 @@ public IEnumerable<UpscaleModelTemplate> GetUpscaleModelTemplates()
3232 public IEnumerable < StableDiffusionModelTemplate > GetStableDiffusionModelTemplates ( )
3333 {
3434 yield return new StableDiffusionModelTemplate ( "SD" , DiffuserPipelineType . StableDiffusion , ModelType . Base , 512 , DiffuserType . TextToImage , DiffuserType . ImageToImage , DiffuserType . ImageInpaintLegacy ) ;
35- yield return new StableDiffusionModelTemplate ( "SD-Inpaint" , DiffuserPipelineType . StableDiffusion , ModelType . Base , 512 , DiffuserType . ImageInpaint ) ;
35+ yield return new StableDiffusionModelTemplate ( "SD-Inpaint" , DiffuserPipelineType . StableDiffusion , ModelType . Base , 512 , DiffuserType . ImageInpaint ) ;
36+ yield return new StableDiffusionModelTemplate ( "SD-ControlNet" , DiffuserPipelineType . StableDiffusion , ModelType . Base , 512 , DiffuserType . ControlNet , DiffuserType . ControlNetImage ) ;
3637
3738 yield return new StableDiffusionModelTemplate ( "SDXL" , DiffuserPipelineType . StableDiffusionXL , ModelType . Base , 1024 , DiffuserType . TextToImage , DiffuserType . ImageToImage , DiffuserType . ImageInpaintLegacy ) ;
3839 yield return new StableDiffusionModelTemplate ( "SDXL-Inpaint" , DiffuserPipelineType . StableDiffusionXL , ModelType . Base , 1024 , DiffuserType . ImageInpaint ) ;
@@ -71,14 +72,20 @@ public StableDiffusionModelSet CreateStableDiffusionModelSet(string name, string
7172 ModelConfigurations = new List < OnnxModelConfig > ( )
7273 } ;
7374
74-
75+ // Some repositories have the ControlNet in the unet folder, some on the controlnet folder
76+ var isControlNet = modelTemplate . DiffuserTypes . Any ( x => x == DiffuserType . ControlNet || x == DiffuserType . ControlNetImage ) ;
7577 var unetPath = Path . Combine ( folder , "unet" , "model.onnx" ) ;
78+ var controlNetUnetPath = Path . Combine ( folder , "controlnet" , "model.onnx" ) ;
79+ if ( isControlNet && File . Exists ( controlNetUnetPath ) )
80+ unetPath = controlNetUnetPath ;
81+
7682 var tokenizerPath = Path . Combine ( folder , "tokenizer" , "model.onnx" ) ;
7783 var textEncoderPath = Path . Combine ( folder , "text_encoder" , "model.onnx" ) ;
7884 var vaeDecoder = Path . Combine ( folder , "vae_decoder" , "model.onnx" ) ;
7985 var vaeEncoder = Path . Combine ( folder , "vae_encoder" , "model.onnx" ) ;
8086 var tokenizer2Path = Path . Combine ( folder , "tokenizer_2" , "model.onnx" ) ;
8187 var textEncoder2Path = Path . Combine ( folder , "text_encoder_2" , "model.onnx" ) ;
88+ var controlnet = Path . Combine ( folder , "controlnet" , "model.onnx" ) ;
8289 if ( ! File . Exists ( tokenizerPath ) )
8390 tokenizerPath = _defaultTokenizerPath ;
8491 if ( ! File . Exists ( tokenizer2Path ) )
0 commit comments