Skip to content

Commit 77f8da6

Browse files
committed
Upscale, Extract, Interpolate views
1 parent e478140 commit 77f8da6

File tree

93 files changed

+5430
-981
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+5430
-981
lines changed

DiffuseApp.sln

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ Global
2323
GlobalSection(ProjectConfigurationPlatforms) = postSolution
2424
{6B186ECB-FAF6-8CD8-DB1C-5B1BFC2AD4E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2525
{6B186ECB-FAF6-8CD8-DB1C-5B1BFC2AD4E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
26-
{6B186ECB-FAF6-8CD8-DB1C-5B1BFC2AD4E7}.Release_Installer|Any CPU.ActiveCfg = Release|Any CPU
27-
{6B186ECB-FAF6-8CD8-DB1C-5B1BFC2AD4E7}.Release_Installer|Any CPU.Build.0 = Release|Any CPU
26+
{6B186ECB-FAF6-8CD8-DB1C-5B1BFC2AD4E7}.Release_Installer|Any CPU.ActiveCfg = Release_Installer|Any CPU
27+
{6B186ECB-FAF6-8CD8-DB1C-5B1BFC2AD4E7}.Release_Installer|Any CPU.Build.0 = Release_Installer|Any CPU
2828
{6B186ECB-FAF6-8CD8-DB1C-5B1BFC2AD4E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
2929
{6B186ECB-FAF6-8CD8-DB1C-5B1BFC2AD4E7}.Release|Any CPU.Build.0 = Release|Any CPU
3030
{10468D82-30E5-3317-2964-66CC582EFE6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@@ -35,8 +35,8 @@ Global
3535
{10468D82-30E5-3317-2964-66CC582EFE6C}.Release|Any CPU.Build.0 = Release|Any CPU
3636
{11638F94-6F86-85DD-CF54-F3CC78C0FBDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3737
{11638F94-6F86-85DD-CF54-F3CC78C0FBDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
38-
{11638F94-6F86-85DD-CF54-F3CC78C0FBDD}.Release_Installer|Any CPU.ActiveCfg = Release|Any CPU
39-
{11638F94-6F86-85DD-CF54-F3CC78C0FBDD}.Release_Installer|Any CPU.Build.0 = Release|Any CPU
38+
{11638F94-6F86-85DD-CF54-F3CC78C0FBDD}.Release_Installer|Any CPU.ActiveCfg = Release_Installer|Any CPU
39+
{11638F94-6F86-85DD-CF54-F3CC78C0FBDD}.Release_Installer|Any CPU.Build.0 = Release_Installer|Any CPU
4040
{11638F94-6F86-85DD-CF54-F3CC78C0FBDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
4141
{11638F94-6F86-85DD-CF54-F3CC78C0FBDD}.Release|Any CPU.Build.0 = Release|Any CPU
4242
EndGlobalSection

DiffuseApp/DiffuseApp.Common/PipelineClient.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,19 @@ public async Task<Tensor<float>> RunAsync(PipelineOptions options, CancellationT
9696
}
9797

9898

99+
/// <summary>
100+
/// Kill server.
101+
/// </summary>
102+
public async Task KillServerAsync()
103+
{
104+
if (_serverProcess is not null)
105+
{
106+
_serverProcess.Kill(true);
107+
await _serverProcess.WaitForExitAsync();
108+
}
109+
}
110+
111+
99112
/// <summary>
100113
/// Send as request to the Server
101114
/// </summary>
@@ -186,7 +199,8 @@ private async Task ProcessProgressQueueAsync(IProgress<PipelineProgress> progres
186199
continue;
187200
}
188201

189-
progressCallback?.Report(await _objectPipe.ReceiveObject<PipelineProgress>(_cancellationTokenSource.Token));
202+
if (!_cancellationTokenSource.IsCancellationRequested)
203+
progressCallback?.Report(await _objectPipe.ReceiveObject<PipelineProgress>(_cancellationTokenSource.Token));
190204
}
191205
catch (OperationCanceledException) { }
192206
catch (Exception ex)

DiffuseApp/DiffuseApp.Server/DiffuseApp.Server.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<TargetFramework>net10.0-windows10.0.17763.0</TargetFramework>
77
<PlatformTarget>x64</PlatformTarget>
88
<ApplicationIcon>Icon.ico</ApplicationIcon>
9-
<Configurations>Debug;Release;</Configurations>
9+
<Configurations>Debug;Release;Release_Installer</Configurations>
1010
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
1111
</PropertyGroup>
1212

DiffuseApp/DiffuseApp/App.xaml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
xmlns:CoreCommon="clr-namespace:TensorStack.Common;assembly=TensorStack.Common"
77
xmlns:CommonControls="clr-namespace:TensorStack.WPF.Controls;assembly=TensorStack.WPF"
88
xmlns:PythonOptions="clr-namespace:TensorStack.Python.Common;assembly=TensorStack.Python"
9+
xmlns:Extractors="clr-namespace:TensorStack.Extractors.Common;assembly=TensorStack.Extractors"
910
xmlns:Common="clr-namespace:Diffuse.Common"
1011
ShutdownMode="OnMainWindowClose">
1112
<Application.Resources>
@@ -115,6 +116,12 @@
115116
</ObjectDataProvider.MethodParameters>
116117
</ObjectDataProvider>
117118

119+
<ObjectDataProvider x:Key="BackgroundMode" MethodName="GetValues" ObjectType="{x:Type System:Enum}">
120+
<ObjectDataProvider.MethodParameters>
121+
<x:Type TypeName="Extractors:BackgroundMode"/>
122+
</ObjectDataProvider.MethodParameters>
123+
</ObjectDataProvider>
124+
118125

119126
<Style x:Key="ImageDropZoneStyle" TargetType="{x:Type Border}">
120127
<Setter Property="AllowDrop" Value="False"/>
@@ -233,12 +240,13 @@
233240
</Style>
234241

235242
<Style x:Key="SubmenuIconButton" TargetType="CommonControls:IconButton">
236-
<Setter Property="Height" Value="70"/>
243+
<Setter Property="Height" Value="60"/>
237244
<Setter Property="Width" Value="120"/>
238245
<Setter Property="LineHeight" Value="14"/>
239246
<Setter Property="Orientation" Value="Vertical"/>
240247
<Setter Property="Placement" Value="Right"/>
241248
<Setter Property="FontSize" Value="12"/>
249+
<Setter Property="FontWeight" Value="Medium"/>
242250
<Setter Property="IconSize" Value="20"/>
243251
<Setter Property="IconStyle" Value="Solid"/>
244252
<Setter Property="IconColor" Value="{StaticResource AccentColour2}"/>
@@ -247,7 +255,23 @@
247255

248256

249257

250-
258+
<DataTemplate x:Key="ComboBoxDataTemplateModel">
259+
<DockPanel>
260+
<CommonControls:FontAwesome DockPanel.Dock="Right" Icon="f019" Size="10" IconStyle="Solid" Opacity=".6" >
261+
<CommonControls:FontAwesome.Style>
262+
<Style TargetType="{x:Type CommonControls:FontAwesome}" BasedOn="{StaticResource {x:Type CommonControls:FontAwesome}}">
263+
<Setter Property="Color" Value="#10FFFFFF"/>
264+
<Style.Triggers>
265+
<DataTrigger Binding="{Binding IsValid}" Value="True">
266+
<Setter Property="Color" Value="{StaticResource AccentColour2}"/>
267+
</DataTrigger>
268+
</Style.Triggers>
269+
</Style>
270+
</CommonControls:FontAwesome.Style>
271+
</CommonControls:FontAwesome>
272+
<TextBlock Text="{Binding Name}" />
273+
</DockPanel>
274+
</DataTemplate>
251275

252276
</ResourceDictionary>
253277

DiffuseApp/DiffuseApp/App.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ public App()
6868
builder.Services.AddSingleton<IMediaService, MediaService>();
6969
builder.Services.AddSingleton<IHistoryService, HistoryService>();
7070
builder.Services.AddSingleton<IUpscaleService, UpscaleService>();
71-
builder.Services.AddSingleton<IExtractorService, ExtractorService>();
71+
builder.Services.AddSingleton<IExtractService, ExtractService>();
7272
builder.Services.AddSingleton<IDiffusionService, DiffusionService>();
7373
builder.Services.AddSingleton<IEnvironmentService, EnvironmentService>();
74+
builder.Services.AddSingleton<IInterpolationService, InterpolationService>();
7475

7576
// Build
7677
_appHost = builder.Build();
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
1-
using TensorStack.WPF;
1+
using System.IO;
2+
using System.Text.Json.Serialization;
3+
using TensorStack.WPF;
24

35
namespace Diffuse.Common
46
{
57
public class ControlNetModel : BaseModel
68
{
9+
private bool _isValid;
10+
711
public int Id { get; init; }
812
public string Name { get; init; }
913
public string Path { get; init; }
1014
public string Pipeline { get; init; }
1115
public bool IsDefault { get; set; }
16+
17+
18+
[JsonIgnore]
19+
public bool IsValid
20+
{
21+
get { return _isValid; }
22+
private set { SetProperty(ref _isValid, value); }
23+
}
24+
25+
public void Initialize(string modelDirectory)
26+
{
27+
var modelId = $"models--{Path.Replace("/", "--")}";
28+
IsValid = Directory.Exists(Path)
29+
|| Directory.Exists(System.IO.Path.Combine(modelDirectory, modelId));
30+
}
1231
}
1332
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using Diffuse.Views;
2+
using System;
3+
using System.Text.Json.Serialization;
4+
5+
namespace Diffuse.Common
6+
{
7+
public record DiffusionHistory : IHistoryItem
8+
{
9+
public int Version { get; init; }
10+
public string Id { get; init; }
11+
12+
public View Source { get; init; }
13+
public MediaType MediaType { get; init; }
14+
public DateTime Timestamp { get; init; }
15+
public string Extension { get; init; }
16+
17+
public string Model { get; init; }
18+
19+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
20+
public string LoraModel { get; init; }
21+
22+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
23+
public string ControlNetModel { get; init; }
24+
25+
public int Width { get; init; }
26+
public int Height { get; init; }
27+
28+
public DiffusionInputOptions Options { get; init; }
29+
30+
31+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
32+
public string ExtractModel { get; init; }
33+
34+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
35+
public ExtractInputOptions ExtractOptions { get; init; }
36+
37+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
38+
public string UpscaleModel { get; init; }
39+
40+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
41+
public UpscaleInputOptions UpscaleOptions { get; init; }
42+
43+
44+
[JsonIgnore]
45+
public string FilePath { get; set; }
46+
47+
[JsonIgnore]
48+
public string MediaPath { get; set; }
49+
50+
[JsonIgnore]
51+
public string ThumbPath { get; set; }
52+
53+
}
54+
}

DiffuseApp/DiffuseApp/Common/GenerateOptions.cs renamed to DiffuseApp/DiffuseApp/Common/DiffusionInputOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Diffuse.Common
99
{
10-
public record GenerateOptions : BaseRecord
10+
public record DiffusionInputOptions : BaseRecord
1111
{
1212
private int _width;
1313
private int _height;
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,39 @@
11
using System.Collections.Generic;
2+
using System.IO;
3+
using System.Text.Json.Serialization;
24
using TensorStack.Python.Common;
35
using TensorStack.WPF;
46

57
namespace Diffuse.Common
68
{
79
public class DiffusionModel : BaseModel
810
{
11+
private bool _isValid;
12+
913
public int Id { get; set; }
1014
public string Name { get; set; }
1115
public string Pipeline { get; set; }
12-
public string ModelUrl { get; set; }
16+
public string Path { get; set; }
1317
public bool IsDefault { get; set; }
1418
public int[] MemoryModes { get; set; }
1519
public DataType[] DataTypes { get; set; }
1620
public ProcessType[] ProcessTypes { get; set; }
1721
public List<SizeOption> Resolutions { get; set; }
1822
public DiffusionDefaultOptions DefaultOptions { get; set; }
23+
24+
25+
[JsonIgnore]
26+
public bool IsValid
27+
{
28+
get { return _isValid; }
29+
private set { SetProperty(ref _isValid, value); }
30+
}
31+
32+
public void Initialize(string modelDirectory)
33+
{
34+
var modelId = $"models--{Path.Replace("/", "--")}";
35+
IsValid = Directory.Exists(Path)
36+
|| Directory.Exists(System.IO.Path.Combine(modelDirectory, modelId));
37+
}
1938
}
2039
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Diffuse.Views;
2+
using System;
3+
using System.Text.Json.Serialization;
4+
5+
namespace Diffuse.Common
6+
{
7+
public record ExtractHistory : IHistoryItem
8+
{
9+
public int Version { get; init; }
10+
public string Id { get; init; }
11+
public View Source { get; init; }
12+
public MediaType MediaType { get; init; }
13+
public DateTime Timestamp { get; init; }
14+
public string Extension { get; init; }
15+
16+
public int Width { get; init; }
17+
public int Height { get; init; }
18+
public string Model { get; init; }
19+
public ExtractInputOptions Options { get; init; }
20+
21+
22+
[JsonIgnore]
23+
public string FilePath { get; set; }
24+
25+
[JsonIgnore]
26+
public string MediaPath { get; set; }
27+
28+
[JsonIgnore]
29+
public string ThumbPath { get; set; }
30+
}
31+
}

0 commit comments

Comments
 (0)