Skip to content

Commit 95580c1

Browse files
committed
v0.4.9 - Fix some errors community found in release
1 parent 07828b3 commit 95580c1

18 files changed

+365
-196
lines changed

DiffuseApp/DiffuseApp/App.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ private async void OnTaskSchedulerException(object sender, UnobservedTaskExcepti
252252
/// <param name="ex">The ex.</param>
253253
private static async Task ShowExceptionMessage(Exception ex)
254254
{
255+
Log.Logger.Error(ex, "[Application] [Exception] An unexpected exception occurred.");
255256
await DialogService.ShowErrorAsync("Unexpected Error", $"An unexpected error occurred:\n{ex.Message}");
256257
}
257258

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using System.Text.Json.Serialization;
2+
using TensorStack.WPF;
3+
4+
namespace Diffuse.Common
5+
{
6+
public sealed class DiffusionCheckpointModel : BaseModel
7+
{
8+
private string _checkpoint;
9+
private string _modelCheckpoint;
10+
private string _vaeCheckpoint;
11+
private string _textEncoderCheckpoint;
12+
13+
/// <summary>
14+
/// Gets or sets the SingleFile checkpoint.
15+
/// </summary>
16+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
17+
public string Checkpoint
18+
{
19+
get { return _checkpoint; }
20+
set { SetProperty(ref _checkpoint, value == string.Empty ? null : value); }
21+
}
22+
23+
/// <summary>
24+
/// Gets or sets the Transformer/Unet checkpoint.
25+
/// </summary>
26+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
27+
public string ModelCheckpoint
28+
{
29+
get { return _modelCheckpoint; }
30+
set { SetProperty(ref _modelCheckpoint, value == string.Empty ? null : value); }
31+
}
32+
33+
/// <summary>
34+
/// Gets or sets the Vae checkpoint.
35+
/// </summary>
36+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
37+
public string VaeCheckpoint
38+
{
39+
get { return _vaeCheckpoint; }
40+
set { SetProperty(ref _vaeCheckpoint, value == string.Empty ? null : value); }
41+
}
42+
43+
44+
/// <summary>
45+
/// Gets or sets the TextEncoder checkpoint.
46+
/// </summary>
47+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
48+
public string TextEncoderCheckpoint
49+
{
50+
get { return _textEncoderCheckpoint; }
51+
set { SetProperty(ref _textEncoderCheckpoint, value == string.Empty ? null : value); }
52+
}
53+
}
54+
}

DiffuseApp/DiffuseApp/Common/DiffusionModel.cs

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public void Initialize(string modelDirectory)
4242
IsValid = Directory.Exists(Path);
4343
else if (Source == ModelSourceType.HuggingFace)
4444
IsValid = Directory.Exists(System.IO.Path.Combine(modelDirectory, Utils.GetHuggingFaceCacheId(Path)));
45+
else if (Source == ModelSourceType.SingleFile)
46+
{
47+
IsValid = Checkpoint is not null && File.Exists(Checkpoint.Checkpoint);
48+
}
4549
else if (Source == ModelSourceType.Checkpoint)
4650
{
4751
IsValid = Checkpoint is not null
@@ -65,30 +69,4 @@ public MemoryProfile(DataType dataType, int[] memoryModes)
6569
public DataType DataType { get; set; }
6670
public int[] MemoryModes { get; set; }
6771
}
68-
69-
70-
public sealed class DiffusionCheckpointModel : BaseModel
71-
{
72-
private string _modelCheckpoint;
73-
private string _vaeCheckpoint;
74-
private string _textEncoderCheckpoint;
75-
76-
public string ModelCheckpoint
77-
{
78-
get { return _modelCheckpoint; }
79-
set { SetProperty(ref _modelCheckpoint, value); }
80-
}
81-
82-
public string VaeCheckpoint
83-
{
84-
get { return _vaeCheckpoint; }
85-
set { SetProperty(ref _vaeCheckpoint, value); }
86-
}
87-
88-
public string TextEncoderCheckpoint
89-
{
90-
get { return _textEncoderCheckpoint; }
91-
set { SetProperty(ref _textEncoderCheckpoint, value); }
92-
}
93-
}
9472
}

DiffuseApp/DiffuseApp/Controls/HistoryControl.xaml

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,40 @@
1717
<CommonControls:BaseControl.Resources>
1818

1919

20+
<Style x:Key="HistoryPopup" TargetType="{x:Type Popup}">
21+
<Setter Property="StaysOpen" Value="True"/>
22+
<Setter Property="PopupAnimation" Value="Fade"/>
23+
<Setter Property="AllowsTransparency" Value="True"/>
24+
<Setter Property="Width" Value="230"/>
25+
<Setter Property="Height" Value="100"/>
26+
<Setter Property="Placement" Value="Top"/>
27+
<Setter Property="VerticalOffset" Value="16"/>
28+
<Setter Property="HorizontalOffset" Value="-2"/>
29+
<Style.Triggers>
30+
<DataTrigger Binding="{Binding Orientation, RelativeSource={RelativeSource AncestorType={x:Type local:HistoryControl}}}" Value="Vertical">
31+
<Setter Property="Placement" Value="Left"/>
32+
<Setter Property="VerticalOffset" Value="-2"/>
33+
<Setter Property="HorizontalOffset" Value="0"/>
34+
</DataTrigger>
35+
</Style.Triggers>
36+
</Style>
37+
38+
<Style x:Key="HistoryContainer" TargetType="{x:Type Border}">
39+
<Setter Property="Margin" Value="0,0,0,18"/>
40+
<Setter Property="CornerRadius" Value="6,6,0,0"/>
41+
<Setter Property="BorderThickness" Value="1,1,1,0"/>
42+
<Setter Property="Background" Value="#80000000"/>
43+
<Setter Property="BorderBrush" Value="{StaticResource ContainerBorder}"/>
44+
<Style.Triggers>
45+
<DataTrigger Binding="{Binding Orientation, RelativeSource={RelativeSource AncestorType={x:Type local:HistoryControl}}}" Value="Vertical">
46+
<Setter Property="Margin" Value="0,0,0,0"/>
47+
<Setter Property="CornerRadius" Value="6,0,0,6"/>
48+
<Setter Property="BorderThickness" Value="1,1,0,1"/>
49+
</DataTrigger>
50+
</Style.Triggers>
51+
</Style>
52+
53+
2054
<!--DiffusionHistory-->
2155
<DataTemplate DataType="{x:Type Common:DiffusionHistory}">
2256
<Grid x:Name="Root" Background="Transparent" >
@@ -56,17 +90,9 @@
5690

5791

5892
<!-- Popup card -->
59-
<Popup x:Name="CardPopup"
60-
Height="100"
61-
Width="230"
62-
VerticalOffset="16"
63-
HorizontalOffset="-2"
64-
Placement="Top"
65-
StaysOpen="True"
66-
PopupAnimation="Slide"
67-
AllowsTransparency="True" >
93+
<Popup x:Name="CardPopup" Style="{StaticResource HistoryPopup}">
6894
<Border Background="#01000000">
69-
<Border Margin="0,0,0,18" Background="#80000000" BorderBrush="{StaticResource ContainerBorder}" BorderThickness="1,1,1,0" CornerRadius="6,6,0,0">
95+
<Border Style="{StaticResource HistoryContainer}" >
7096
<StackPanel Margin="6,4,6,6">
7197
<TextBlock Text="{Binding Source}" />
7298
<TextBlock Text="{Binding Width, StringFormat={}Width: {0}}" />
@@ -101,7 +127,7 @@
101127
</EventTrigger>
102128
</Grid.Triggers>
103129

104-
130+
105131
</Grid>
106132
</DataTemplate>
107133

@@ -145,17 +171,9 @@
145171

146172

147173
<!-- Popup card -->
148-
<Popup x:Name="CardPopup"
149-
Height="100"
150-
Width="230"
151-
VerticalOffset="16"
152-
HorizontalOffset="-2"
153-
Placement="Top"
154-
StaysOpen="True"
155-
PopupAnimation="Slide"
156-
AllowsTransparency="True" >
174+
<Popup x:Name="CardPopup" Style="{StaticResource HistoryPopup}">
157175
<Border Background="#01000000">
158-
<Border Margin="0,0,0,18" Background="#80000000" BorderBrush="{StaticResource ContainerBorder}" BorderThickness="1,1,1,0" CornerRadius="6,6,0,0">
176+
<Border Style="{StaticResource HistoryContainer}" >
159177
<StackPanel Margin="6,4,6,6">
160178
<TextBlock Text="{Binding Source}" />
161179
<TextBlock Text="{Binding Width, StringFormat={}Width: {0}}" />
@@ -233,17 +251,9 @@
233251

234252

235253
<!-- Popup card -->
236-
<Popup x:Name="CardPopup"
237-
Height="100"
238-
Width="230"
239-
VerticalOffset="16"
240-
HorizontalOffset="-2"
241-
Placement="Top"
242-
StaysOpen="True"
243-
PopupAnimation="Slide"
244-
AllowsTransparency="True" >
254+
<Popup x:Name="CardPopup" Style="{StaticResource HistoryPopup}">
245255
<Border Background="#01000000">
246-
<Border Margin="0,0,0,18" Background="#80000000" BorderBrush="{StaticResource ContainerBorder}" BorderThickness="1,1,1,0" CornerRadius="6,6,0,0">
256+
<Border Style="{StaticResource HistoryContainer}" >
247257
<StackPanel Margin="6,4,6,6">
248258
<TextBlock Text="{Binding Source}" />
249259
<TextBlock Text="{Binding Width, StringFormat={}Width: {0}}" />
@@ -321,17 +331,9 @@
321331

322332

323333
<!-- Popup card -->
324-
<Popup x:Name="CardPopup"
325-
Height="100"
326-
Width="230"
327-
VerticalOffset="16"
328-
HorizontalOffset="-2"
329-
Placement="Top"
330-
StaysOpen="True"
331-
PopupAnimation="Slide"
332-
AllowsTransparency="True" >
334+
<Popup x:Name="CardPopup" Style="{StaticResource HistoryPopup}">
333335
<Border Background="#01000000">
334-
<Border Margin="0,0,0,18" Background="#80000000" BorderBrush="{StaticResource ContainerBorder}" BorderThickness="1,1,1,0" CornerRadius="6,6,0,0">
336+
<Border Style="{StaticResource HistoryContainer}" >
335337
<StackPanel Margin="6,4,6,6">
336338
<TextBlock Text="{Binding Source}" />
337339
<TextBlock Text="{Binding Width, StringFormat={}Width: {0}}" />
@@ -416,7 +418,6 @@
416418
</ControlTemplate>
417419
</Setter.Value>
418420
</Setter>
419-
420421
</Style>
421422
</ListBox.ItemContainerStyle>
422423
</ListBox>

0 commit comments

Comments
 (0)