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

Commit 90bb9f1

Browse files
authored
Merge pull request #100 from saddam213/ControlNet
ControlNet Improvements
2 parents 3c4e470 + 68fa37f commit 90bb9f1

File tree

6 files changed

+37
-9
lines changed

6 files changed

+37
-9
lines changed

OnnxStack.StableDiffusion/Config/ControlNetModelSet.cs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace OnnxStack.StableDiffusion.Config
88
public record ControlNetModelSet : IOnnxModelSetConfig
99
{
1010
public ControlNetType Type { get; set; }
11+
public DiffuserPipelineType PipelineType { get; set; }
1112
public string Name { get; set; }
1213
public bool IsEnabled { get; set; }
1314
public int DeviceId { get; set; }

OnnxStack.UI/Dialogs/AddControlNetModelDialog.xaml

+12-6
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@
1818
<DockPanel DataContext="{Binding ElementName=UI}" Margin="15, 15, 15, 10">
1919
<StackPanel DockPanel.Dock="Top">
2020

21-
<StackPanel>
22-
<TextBlock Text="Model Type"/>
23-
<ComboBox ItemsSource="{Binding Source={StaticResource ControlNetType}}" SelectedItem="{Binding SelectedControlNetType}" />
24-
</StackPanel>
21+
<UniformGrid Columns="2">
22+
<StackPanel>
23+
<TextBlock Text="Model Type"/>
24+
<ComboBox ItemsSource="{Binding Source={StaticResource ControlNetType}}" SelectedItem="{Binding SelectedControlNetType}" />
25+
</StackPanel>
2526

27+
<StackPanel Margin="5,0,0,0">
28+
<TextBlock Text="Pipeline Type"/>
29+
<ComboBox ItemsSource="{Binding Source={StaticResource DiffuserPipelineType}}" SelectedItem="{Binding SelectedPipelineType}" />
30+
</StackPanel>
31+
</UniformGrid>
2632

2733
<StackPanel Margin="0,10,0,0">
2834
<TextBlock Text="Control Model File"/>
@@ -40,7 +46,7 @@
4046
</StackPanel>
4147

4248
<StackPanel Margin="5">
43-
49+
4450

4551
<ItemsControl ItemsSource="{Binding ValidationResults}">
4652
<ItemsControl.ItemTemplate>
@@ -65,7 +71,7 @@
6571
</DataTemplate>
6672
</ItemsControl.ItemTemplate>
6773
</ItemsControl>
68-
74+
6975
</StackPanel>
7076

7177

OnnxStack.UI/Dialogs/AddControlNetModelDialog.xaml.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ public ControlNetType SelectedControlNetType
8383

8484
}
8585

86+
private DiffuserPipelineType _selectedPipelineType;
87+
88+
public DiffuserPipelineType SelectedPipelineType
89+
{
90+
get { return _selectedPipelineType; }
91+
set { _selectedPipelineType = value; NotifyPropertyChanged(); CreateModelSet(); }
92+
}
93+
94+
8695
public ControlNetModelSet ModelSetResult
8796
{
8897
get { return _modelSetResult; }
@@ -102,7 +111,7 @@ private void CreateModelSet()
102111
if (string.IsNullOrEmpty(_modelFile))
103112
return;
104113

105-
_modelSetResult = _modelFactory.CreateControlNetModelSet(ModelName.Trim(), _selectedControlNetType, _modelFile, _annotationModelFile);
114+
_modelSetResult = _modelFactory.CreateControlNetModelSet(ModelName.Trim(), _selectedControlNetType, _selectedPipelineType, _modelFile, _annotationModelFile);
106115

107116
// Validate
108117
ValidationResults.Add(new ValidationResult("Name", !_invalidOptions.Contains(_modelName, StringComparer.OrdinalIgnoreCase) && _modelName.Length > 2 && _modelName.Length < 50));

OnnxStack.UI/Models/UpdateControlNetModelSetViewModel.cs

+11
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public class UpdateControlNetModelSetViewModel : INotifyPropertyChanged
2121
private ExecutionProvider _executionProvider;
2222
private ObservableCollection<ModelFileViewModel> _modelFiles;
2323
private ControlNetType _controlNetType;
24+
private DiffuserPipelineType _pipelineType;
25+
2426

2527
public string Name
2628
{
@@ -33,6 +35,13 @@ public ControlNetType ControlNetType
3335
get { return _controlNetType; }
3436
set { _controlNetType = value; NotifyPropertyChanged(); }
3537
}
38+
39+
public DiffuserPipelineType PipelineType
40+
{
41+
get { return _pipelineType; }
42+
set { _pipelineType = value; NotifyPropertyChanged(); }
43+
}
44+
3645
public int DeviceId
3746
{
3847
get { return _deviceId; }
@@ -76,6 +85,7 @@ public static UpdateControlNetModelSetViewModel FromModelSet(ControlNetModelSet
7685
{
7786
Name = modelset.Name,
7887
ControlNetType = modelset.Type,
88+
PipelineType = modelset.PipelineType,
7989
DeviceId = modelset.DeviceId,
8090
ExecutionMode = modelset.ExecutionMode,
8191
ExecutionProvider = modelset.ExecutionProvider,
@@ -107,6 +117,7 @@ public static ControlNetModelSet ToModelSet(UpdateControlNetModelSetViewModel mo
107117
IsEnabled = true,
108118
Name = modelset.Name,
109119
Type = modelset.ControlNetType,
120+
PipelineType = modelset.PipelineType,
110121
DeviceId = modelset.DeviceId,
111122
ExecutionMode = modelset.ExecutionMode,
112123
ExecutionProvider = modelset.ExecutionProvider,

OnnxStack.UI/Services/IModelFactory.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ public interface IModelFactory
1212

1313
UpscaleModelSet CreateUpscaleModelSet(string name, string filename, UpscaleModelTemplate modelTemplate);
1414
StableDiffusionModelSet CreateStableDiffusionModelSet(string name, string folder, StableDiffusionModelTemplate modelTemplate);
15-
ControlNetModelSet CreateControlNetModelSet(string name, ControlNetType controlNetType, string modelFilename, string annotationFilename);
15+
ControlNetModelSet CreateControlNetModelSet(string name, ControlNetType controlNetType, DiffuserPipelineType pipelineType, string modelFilename, string annotationFilename);
1616
}
1717
}

OnnxStack.UI/Services/ModelFactory.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public UpscaleModelSet CreateUpscaleModelSet(string name, string filename, Upsca
152152
}
153153

154154

155-
public ControlNetModelSet CreateControlNetModelSet(string name, ControlNetType controlNetType, string modelFilename, string annotationFilename)
155+
public ControlNetModelSet CreateControlNetModelSet(string name, ControlNetType controlNetType, DiffuserPipelineType pipelineType, string modelFilename, string annotationFilename)
156156
{
157157
var models = new List<OnnxModelConfig> { new OnnxModelConfig { Type = OnnxModelType.ControlNet, OnnxModelPath = modelFilename } };
158158
if (!string.IsNullOrEmpty(annotationFilename))
@@ -162,6 +162,7 @@ public ControlNetModelSet CreateControlNetModelSet(string name, ControlNetType c
162162
{
163163
Name = name,
164164
Type = controlNetType,
165+
PipelineType = pipelineType,
165166
ModelConfigurations = models,
166167

167168
IsEnabled = true,

0 commit comments

Comments
 (0)