55using System . Security . Cryptography . X509Certificates ;
66using System . Text ;
77using System . Threading . Tasks ;
8+ using System . Windows . Automation ;
89
910namespace SD_FXUI
1011{
1112 class ControlNetBase
1213 {
14+ protected HelperControlNet . ControlTypes ControlType ;
1315 protected string Model = "" ;
1416 protected string CNModel = "" ;
1517 protected string BaseOutPath = FS . GetModelDir ( ) + "controlnet/gen/" ;
@@ -70,6 +72,7 @@ public ControlNetOpenPose()
7072 {
7173 Model = "sd-controlnet-openpose" ;
7274 CNModel = "sd-controlnet/anannotator/ckpts/" ;
75+ ControlType = HelperControlNet . ControlTypes . OpenPose ;
7376 }
7477
7578 public override void CheckSD ( )
@@ -87,7 +90,7 @@ public override void CheckCN()
8790 if ( ! System . IO . File . Exists ( GetModelPathCN ( ) + "hand_pose_model.pth" ) )
8891 {
8992 Notification . SendNotification ( "Starting downloading pose model..." ) ;
90- WGetDownloadModels . DownloadCNPoser ( HelperControlNet . ControlTypes . Poser ) ;
93+ WGetDownloadModels . DownloadCNPoser ( ControlType ) ;
9194 Notification . SendNotification ( "Download pose model: done!" ) ;
9295 }
9396 }
@@ -110,6 +113,7 @@ public ControlNetFace()
110113 Model = "sd-controlnet-facegen" ;
111114 CNModel = "" ;
112115
116+ ControlType = HelperControlNet . ControlTypes . MediapipeFace ;
113117 System . IO . Directory . CreateDirectory ( Outdir ( ) ) ;
114118 }
115119
@@ -140,6 +144,7 @@ public ControlNetHed()
140144 {
141145 Model = "sd-controlnet-hed" ;
142146 CNModel = "sd-controlnet/anannotator/ckpts/network-bsds500.pth" ;
147+ ControlType = HelperControlNet . ControlTypes . Hed ;
143148
144149 System . IO . Directory . CreateDirectory ( Outdir ( ) ) ;
145150 }
@@ -159,7 +164,7 @@ public override void CheckCN()
159164 if ( ! System . IO . File . Exists ( GetModelPathCN ( ) ) )
160165 {
161166 Notification . SendNotification ( "Starting downloading hed model..." ) ;
162- WGetDownloadModels . DownloadCNPoser ( HelperControlNet . ControlTypes . Hed ) ;
167+ WGetDownloadModels . DownloadCNPoser ( ControlType ) ;
163168 Notification . SendNotification ( "Download hed model: done!" ) ;
164169 }
165170 }
@@ -180,6 +185,7 @@ public ControlNetCanny()
180185 {
181186 Model = "sd-controlnet-canny" ;
182187 CNModel = "" ;
188+ ControlType = HelperControlNet . ControlTypes . Canny ;
183189
184190 System . IO . Directory . CreateDirectory ( Outdir ( ) ) ;
185191 }
@@ -210,6 +216,7 @@ public ControlNetDepth()
210216 {
211217 Model = "sd-controlnet-depth" ;
212218 CNModel = "" ;
219+ ControlType = HelperControlNet . ControlTypes . Depth ;
213220
214221 System . IO . Directory . CreateDirectory ( Outdir ( ) ) ;
215222 }
@@ -241,6 +248,7 @@ public ControlNetNormal()
241248 {
242249 Model = "sd-controlnet-normal" ;
243250 CNModel = "" ;
251+ ControlType = HelperControlNet . ControlTypes . NormalMap ;
244252
245253 System . IO . Directory . CreateDirectory ( Outdir ( ) ) ;
246254 }
@@ -271,6 +279,7 @@ public ControlNetScribble()
271279 {
272280 Model = "sd-controlnet-scribble" ;
273281 CNModel = "sd-controlnet/anannotator/ckpts/network-bsds500.pth" ;
282+ ControlType = HelperControlNet . ControlTypes . Scribble ;
274283
275284 System . IO . Directory . CreateDirectory ( Outdir ( ) ) ;
276285 }
@@ -301,6 +310,7 @@ public ControlNetSeg()
301310 {
302311 Model = "sd-controlnet-seg" ;
303312 CNModel = "" ;
313+ ControlType = HelperControlNet . ControlTypes . Segmentation ;
304314
305315 System . IO . Directory . CreateDirectory ( Outdir ( ) ) ;
306316 }
@@ -331,6 +341,7 @@ public ControlNetMLSD()
331341 {
332342 Model = "sd-controlnet-mlsd" ;
333343 CNModel = "sd-controlnet\\ anannotator\\ ckpts\\ mlsd_large_512_fp32.pth" ;
344+ ControlType = HelperControlNet . ControlTypes . Mlsd ;
334345
335346 System . IO . Directory . CreateDirectory ( Outdir ( ) ) ;
336347 }
@@ -350,7 +361,7 @@ public override void CheckCN()
350361 if ( ! System . IO . File . Exists ( GetModelPathCN ( ) ) )
351362 {
352363 Notification . SendNotification ( "Starting downloading mlsd model..." ) ;
353- WGetDownloadModels . DownloadCNPoser ( HelperControlNet . ControlTypes . Mlsd ) ;
364+ WGetDownloadModels . DownloadCNPoser ( ControlType ) ;
354365 Notification . SendNotification ( "Download mlsd model: done!" ) ;
355366 }
356367 }
@@ -388,7 +399,7 @@ public enum ControlTypes
388399 Hed ,
389400 NormalMap ,
390401 OpenPose ,
391- OpenPose_hand ,
402+ MediapipeFace ,
392403 Clip_vision ,
393404 Color ,
394405 Pidinet ,
@@ -398,5 +409,32 @@ public enum ControlTypes
398409 Fake_Scribble ,
399410 Binary
400411 }
412+
413+ public static ControlNetBase GetType ( string StrData )
414+ {
415+ string LoverName = StrData . ToLower ( ) ;
416+
417+ if ( LoverName == "canny" ) return Canny ;
418+ if ( LoverName == "depth" ) return Depth ;
419+ if ( LoverName == "hed" ) return Hed ;
420+ if ( LoverName == "normalmap" ) return Normal ;
421+ if ( LoverName == "openposedetector" ) return OpenPose ;
422+ if ( LoverName == "scribble" ) return Scribble ;
423+ if ( LoverName == "segmentation" ) return Seg ;
424+ if ( LoverName == "mlsd" ) return MLSD ;
425+ if ( LoverName == "facegen" ) return Face ;
426+
427+ /*
428+ if (LoverName == "depth_leres") ; // not implemented return canny
429+ if (LoverName == "openpose_hand") ; // not implemented return canny
430+ if (LoverName == "clip_vision") ; // not implemented return canny
431+ if (LoverName == "fake_scribble") ; // not implemented return canny
432+ if (LoverName == "pidinet") ; // not implemented return canny
433+ if (LoverName == "binary") ; // not implemented return canny
434+ */
435+
436+ return HelperControlNet . Canny ; // temp Bypass error;
437+
438+ }
401439 }
402440}
0 commit comments