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

Commit 3d9d922

Browse files
committed
Add memory mode to UI
1 parent 2a1d771 commit 3d9d922

File tree

7 files changed

+35
-5
lines changed

7 files changed

+35
-5
lines changed

OnnxStack.UI/App.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@
112112
</ObjectDataProvider.MethodParameters>
113113
</ObjectDataProvider>
114114

115+
<ObjectDataProvider x:Key="MemoryModeType" MethodName="GetValues" ObjectType="{x:Type system:Enum}">
116+
<ObjectDataProvider.MethodParameters>
117+
<x:Type TypeName="SD_Enums:MemoryModeType"/>
118+
</ObjectDataProvider.MethodParameters>
119+
</ObjectDataProvider>
120+
115121

116122
<!--Crop Image Dialog-->
117123
<SolidColorBrush x:Key="CropFrameBrush" Color="#FF3296FA" />

OnnxStack.UI/Dialogs/UpdateModelDialog.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@
6565
DeviceId="{Binding UpdateModelSet.DeviceId, Mode=TwoWay}"
6666
ExecutionProvider="{Binding UpdateModelSet.ExecutionProvider, Mode=TwoWay}" />
6767
</StackPanel>
68+
<StackPanel Margin="0,5,0,0">
69+
<TextBlock Text="Memory Mode" />
70+
<ComboBox ItemsSource="{Binding Source={StaticResource MemoryModeType}}" SelectedItem="{Binding UpdateModelSet.MemoryMode}" />
71+
</StackPanel>
6872
<StackPanel Margin="0,4,0,0">
69-
<TextBlock Text="Mode" />
73+
<TextBlock Text="Execution Mode" />
7074
<ComboBox ItemsSource="{Binding Source={StaticResource ExecutionModeType}}" SelectedItem="{Binding UpdateModelSet.ExecutionMode}" />
7175
</StackPanel>
7276
<UniformGrid Columns="2" Margin="0,4,0,0">

OnnxStack.UI/Models/OnnxStackUIConfig.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Microsoft.ML.OnnxRuntime;
22
using OnnxStack.Common.Config;
33
using OnnxStack.Core.Config;
4+
using OnnxStack.StableDiffusion.Enums;
45
using System.Collections.Generic;
56
using System.Collections.ObjectModel;
67
using System.Linq;
@@ -15,6 +16,7 @@ public class OnnxStackUIConfig : IConfigSection
1516
public int DefaultIntraOpNumThreads { get; set; }
1617
public ExecutionMode DefaultExecutionMode { get; set; }
1718
public ExecutionProvider DefaultExecutionProvider { get; set; }
19+
public MemoryModeType DefaultMemoryMode { get; set; }
1820

1921
[JsonIgnore]
2022
public ExecutionProvider SupportedExecutionProvider => GetSupportedExecutionProvider();

OnnxStack.UI/Models/UpdateStableDiffusionModelSetViewModel.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,15 @@ public DiffuserPipelineType PipelineType
165165
set { _pipelineType = value; NotifyPropertyChanged(); }
166166
}
167167

168+
private MemoryModeType _memoryMode;
169+
170+
public MemoryModeType MemoryMode
171+
{
172+
get { return _memoryMode; }
173+
set { _memoryMode = value; NotifyPropertyChanged(); }
174+
}
175+
176+
168177
private ModelType _modelType;
169178

170179
public ModelType ModelType
@@ -250,6 +259,7 @@ public static UpdateStableDiffusionModelSetViewModel FromModelSet(StableDiffusio
250259
ExecutionProvider = modelset.ExecutionProvider,
251260
InterOpNumThreads = modelset.InterOpNumThreads,
252261
IntraOpNumThreads = modelset.IntraOpNumThreads,
262+
MemoryMode = modelset.MemoryMode,
253263

254264
Name = modelset.Name,
255265
PipelineType = modelset.PipelineType,
@@ -402,6 +412,8 @@ public static StableDiffusionModelSet ToModelSet(UpdateStableDiffusionModelSetVi
402412
InterOpNumThreads = modelset.InterOpNumThreads,
403413
IntraOpNumThreads = modelset.IntraOpNumThreads,
404414

415+
MemoryMode = modelset.MemoryMode,
416+
405417
UnetConfig = new UNetConditionModelConfig
406418
{
407419
ModelType = modelset.ModelType,

OnnxStack.UI/Services/ModelFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public StableDiffusionModelSet CreateStableDiffusionModelSet(string name, string
6161
ExecutionProvider = _settings.DefaultExecutionProvider,
6262
InterOpNumThreads = _settings.DefaultInterOpNumThreads,
6363
IntraOpNumThreads = _settings.DefaultIntraOpNumThreads,
64+
MemoryMode = _settings.DefaultMemoryMode,
6465
IsEnabled = true,
6566
};
6667

OnnxStack.UI/Views/SettingsView.xaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,14 @@
6565
DeviceId="{Binding UISettings.DefaultDeviceId, Mode=TwoWay}"
6666
ExecutionProvider="{Binding UISettings.DefaultExecutionProvider, Mode=TwoWay}" />
6767
</StackPanel>
68-
68+
69+
<StackPanel Margin="0,5,0,0">
70+
<TextBlock Text="Memory Mode" />
71+
<ComboBox ItemsSource="{Binding Source={StaticResource MemoryModeType}}" SelectedItem="{Binding UISettings.DefaultMemoryMode}" />
72+
</StackPanel>
73+
6974
<StackPanel Margin="0,5,0,0">
70-
<TextBlock Text="Mode" />
75+
<TextBlock Text="Execution Mode" />
7176
<ComboBox ItemsSource="{Binding Source={StaticResource ExecutionModeType}}" SelectedItem="{Binding UISettings.DefaultExecutionMode}" />
7277
</StackPanel>
7378

OnnxStack.UI/appsettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"Logging": {
33
"LogLevel": {
4-
"Default": "Information",
5-
"Microsoft.AspNetCore": "Warning"
4+
"Default": "Debug",
5+
"Microsoft": "Warning"
66
}
77
},
88
"AllowedHosts": "*",

0 commit comments

Comments
 (0)