Skip to content

Commit 93a4b29

Browse files
committed
ControlNet minor update
1 parent b984aa7 commit 93a4b29

File tree

3 files changed

+44
-32
lines changed

3 files changed

+44
-32
lines changed

ui-src/Components/HelperControlNet.cs

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
using System.Security.Cryptography.X509Certificates;
66
using System.Text;
77
using System.Threading.Tasks;
8+
using System.Windows.Automation;
89

910
namespace 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
}

ui-src/MainWindow.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ private void btnInImgPose_Click(object sender, RoutedEventArgs e)
822822
{
823823
string CurrentImg = Helper.InputImagePath;
824824

825-
ControlNetBase CN = GetCNType(cbExtractPoseSelector.Text);
825+
ControlNetBase CN = HelperControlNet.GetType(cbExtractPoseSelector.Text);
826826
Task.Run(() => CMD.PoserProcess(CurrentImg, CN));
827827

828828
cbControlNetMode.SelectedIndex = cbExtractPoseSelector.SelectedIndex;
@@ -960,7 +960,7 @@ private void cbControlNetMode_SelectionChanged(object sender, SelectionChangedEv
960960

961961
string NewMode = ((ComboBoxItem)e.AddedItems[0]).Content.ToString();
962962

963-
HelperControlNet.Current = GetCNType(NewMode);
963+
HelperControlNet.Current = HelperControlNet.GetType(NewMode);
964964

965965
UpdateModelsListControlNet();
966966
cbPose.IsEnabled = true;

ui-src/MainWindows.xaml.helper.cs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -586,32 +586,6 @@ private string FixedPrompt(string Text)
586586

587587
}
588588

589-
ControlNetBase GetCNType(string ComboBox)
590-
{
591-
string LoverName = ComboBox.ToLower();
592-
593-
if (LoverName == "canny") return HelperControlNet.Canny;
594-
if (LoverName == "depth") return HelperControlNet.Depth;
595-
if (LoverName == "hed") return HelperControlNet.Hed;
596-
if (LoverName == "normalmap") return HelperControlNet.Normal;
597-
if (LoverName == "openposedetector") return HelperControlNet.OpenPose;
598-
if (LoverName == "scribble") return HelperControlNet.Scribble;
599-
if (LoverName == "segmentation") return HelperControlNet.Seg;
600-
if (LoverName == "mlsd") return HelperControlNet.MLSD;
601-
if (LoverName == "facegen") return HelperControlNet.Face;
602-
603-
/*
604-
if (LoverName == "depth_leres") ; // not implemented return canny
605-
if (LoverName == "openpose_hand") ; // not implemented return canny
606-
if (LoverName == "clip_vision") ; // not implemented return canny
607-
if (LoverName == "fake_scribble") ; // not implemented return canny
608-
if (LoverName == "pidinet") ; // not implemented return canny
609-
if (LoverName == "binary") ; // not implemented return canny
610-
*/
611-
612-
return HelperControlNet.Canny; // temp Bypass error;
613-
614-
}
615589
public void UpdateModelsListControlNet()
616590
{
617591
cbPose.Items.Clear();

0 commit comments

Comments
 (0)