Skip to content

Commit 53a1242

Browse files
committed
v0.4.3 - Upscale OOM fixes, Background Extractor optimization bugfix
1 parent 2e4033e commit 53a1242

14 files changed

+75
-68
lines changed
-19 KB
Binary file not shown.
-19 KB
Binary file not shown.
-19 KB
Binary file not shown.

DiffuseApp/DiffuseApp/Controls/ModelControl.xaml.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,9 @@ private bool CanLoad()
153153

154154
private Task UnloadAsync()
155155
{
156-
SelectedExtractor = default;
157156
_currentExtractor = default;
158-
159-
SelectedUpscaler = default;
160157
_currentUpscaler = default;
161-
162-
CurrentPipeline = new PipelineModel
163-
{
164-
Device = _selectedDevice
165-
};
166-
167-
SelectionChanged?.Invoke(this, CurrentPipeline);
158+
SelectionChanged?.Invoke(this, default);
168159
return Task.CompletedTask;
169160
}
170161

DiffuseApp/DiffuseApp/Dialogs/MediaPreviewDialog.xaml.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,21 @@ public VideoInputStream CurrentVideoStream
6060
}
6161

6262

63-
public Task<bool> ShowDialogAsync(IHistoryItem selectedItem)
63+
public async Task<bool> ShowDialogAsync(IHistoryItem selectedItem)
6464
{
6565
HistoryCollection.MoveCurrentTo(selectedItem);
66-
SetCurrentImage();
67-
return base.ShowDialogAsync();
66+
await SetCurrentImage();
67+
return await base.ShowDialogAsync();
6868
}
6969

7070

71-
private Task PrevAsync()
71+
private async Task PrevAsync()
7272
{
7373
if (CanMovePrev())
7474
{
7575
HistoryCollection.MoveCurrentToPrevious();
76-
SetCurrentImage();
76+
await SetCurrentImage();
7777
}
78-
79-
return Task.CompletedTask;
8078
}
8179

8280

DiffuseApp/DiffuseApp/Services/ExtractService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public async Task LoadAsync(PipelineModel pipeline)
117117
SampleSize = model.SampleSize
118118
};
119119

120-
_currentConfig.SetProvider(device.GetProvider());
120+
_currentConfig.SetProvider(device.GetProvider(Microsoft.ML.OnnxRuntime.GraphOptimizationLevel.ORT_DISABLE_ALL));
121121
_extractPipeline = model.Type switch
122122
{
123123
ExtractorType.Pose => PosePipeline.Create(_currentConfig),

DiffuseApp/DiffuseApp/Settings.default.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
"ScaleFactor": 4,
153153
"DefaultOptions": {
154154
"TileMode": "ClipBlend",
155-
"TileSize": 512,
155+
"TileSize": 384,
156156
"TileOverlap": 16
157157
},
158158
"UrlPaths": [ "https://huggingface.co/TensorStack/Diffuse/resolve/main/Upscale/APISR-GRL-GAN-4x/model.onnx" ]
@@ -204,7 +204,7 @@
204204
"ScaleFactor": 4,
205205
"DefaultOptions": {
206206
"TileMode": "ClipBlend",
207-
"TileSize": 512,
207+
"TileSize": 384,
208208
"TileOverlap": 16
209209
},
210210
"UrlPaths": [ "https://huggingface.co/TensorStack/Diffuse/resolve/main/Upscale/RealESRGAN-4x/model.onnx" ]
@@ -217,7 +217,7 @@
217217
"ScaleFactor": 4,
218218
"DefaultOptions": {
219219
"TileMode": "ClipBlend",
220-
"TileSize": 512,
220+
"TileSize": 1024,
221221
"TileOverlap": 16
222222
},
223223
"UrlPaths": [ "https://huggingface.co/TensorStack/Diffuse/resolve/main/Upscale/RealESR-General-4x/model.onnx" ]
@@ -230,7 +230,7 @@
230230
"ScaleFactor": 4,
231231
"DefaultOptions": {
232232
"TileMode": "ClipBlend",
233-
"TileSize": 512,
233+
"TileSize": 256,
234234
"TileOverlap": 16
235235
},
236236
"UrlPaths": [ "https://huggingface.co/TensorStack/Diffuse/resolve/main/Upscale/RealWebPhoto-RGT-4x/model.onnx" ]
@@ -243,7 +243,7 @@
243243
"ScaleFactor": 2,
244244
"DefaultOptions": {
245245
"TileMode": "ClipBlend",
246-
"TileSize": 512,
246+
"TileSize": 384,
247247
"TileOverlap": 16
248248
},
249249
"UrlPaths": [ "https://huggingface.co/TensorStack/Diffuse/resolve/main/Upscale/Swin2SR-Classical-2x/model.onnx" ]
@@ -256,7 +256,7 @@
256256
"ScaleFactor": 4,
257257
"DefaultOptions": {
258258
"TileMode": "ClipBlend",
259-
"TileSize": 512,
259+
"TileSize": 384,
260260
"TileOverlap": 16
261261
},
262262
"UrlPaths": [ "https://huggingface.co/TensorStack/Diffuse/resolve/main/Upscale/Swin2SR-Classical-4x/model.onnx" ]
@@ -269,7 +269,7 @@
269269
"ScaleFactor": 4,
270270
"DefaultOptions": {
271271
"TileMode": "ClipBlend",
272-
"TileSize": 512,
272+
"TileSize": 256,
273273
"TileOverlap": 16
274274
},
275275
"UrlPaths": [ "https://huggingface.co/TensorStack/Diffuse/resolve/main/Upscale/Swin2SR-RealWorld-BSRGAN-PSN-4x/model.onnx" ]
@@ -282,7 +282,7 @@
282282
"ScaleFactor": 4,
283283
"DefaultOptions": {
284284
"TileMode": "ClipBlend",
285-
"TileSize": 512,
285+
"TileSize": 384,
286286
"TileOverlap": 16
287287
},
288288
"UrlPaths": [ "https://huggingface.co/TensorStack/Diffuse/resolve/main/Upscale/SwinIR-BSRGAN-4x/model.onnx" ]
@@ -294,7 +294,7 @@
294294
"SampleSize": 0,
295295
"DefaultOptions": {
296296
"TileMode": "ClipBlend",
297-
"TileSize": 512,
297+
"TileSize": 384,
298298
"TileOverlap": 16
299299
},
300300
"ScaleFactor": 4,
@@ -308,7 +308,7 @@
308308
"ScaleFactor": 4,
309309
"DefaultOptions": {
310310
"TileMode": "ClipBlend",
311-
"TileSize": 512,
311+
"TileSize": 384,
312312
"TileOverlap": 16
313313
},
314314
"UrlPaths": [ "https://huggingface.co/TensorStack/Diffuse/resolve/main/Upscale/UltraSharp-4x/model.onnx" ]

DiffuseApp/DiffuseApp/Views/ImageExtractView.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<Grid Margin="10,10,10,2" >
9797
<CommonControls:ImageElement
9898
SplitterVisibility="Auto"
99-
SplitterPosition="Center"
99+
SplitterPosition="Source"
100100
SplitterDirection="LeftToRight"
101101
Source="{Binding ResultImage, Mode=TwoWay}"
102102
OverlaySource="{Binding CompareImage, Mode=TwoWay}"

DiffuseApp/DiffuseApp/Views/ImageExtractView.xaml.cs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Diagnostics;
66
using System.IO;
77
using System.Threading.Tasks;
8-
98
using TensorStack.Image;
109
using TensorStack.WPF;
1110
using TensorStack.WPF.Controls;
@@ -31,22 +30,6 @@ public ImageExtractView(Settings settings, NavigationService navigationService,
3130
ExtractService = extractService;
3231
ExecuteCommand = new AsyncRelayCommand(ExecuteAsync, CanExecute);
3332
CancelCommand = new AsyncRelayCommand(CancelAsync, CanCancel);
34-
Options = new ExtractInputOptions
35-
{
36-
TileSize = 512,
37-
TileOverlap = 16,
38-
IsInverted = false,
39-
MergeInput = false,
40-
Mode = TensorStack.Extractors.Common.BackgroundMode.RemoveBackground,
41-
Detections = 0,
42-
BodyConfidence = 0.4f,
43-
JointConfidence = 0.1f,
44-
ColorAlpha = 0.8f,
45-
JointRadius = 7f,
46-
BoneRadius = 8f,
47-
BoneThickness = 1f,
48-
IsTransparent = false
49-
};
5033
InitializeComponent();
5134
}
5235

@@ -223,14 +206,21 @@ private bool CanCancel()
223206

224207
protected async void SelectedExtractorChanged(object sender, PipelineModel pipeline)
225208
{
226-
if (pipeline.ExtractModel is not null && !pipeline.ExtractModel.IsValid)
209+
if (pipeline?.ExtractModel == null)
227210
{
228-
if (!await pipeline.ExtractModel.DownloadAsync(Path.Combine(Settings.DirectoryModel, "Extract")))
229-
CurrentPipeline = default;
211+
await UnloadPipelineAsync();
230212
}
213+
else
214+
{
215+
if (pipeline.ExtractModel is not null && !pipeline.ExtractModel.IsValid)
216+
{
217+
if (!await pipeline.ExtractModel.DownloadAsync(Path.Combine(Settings.DirectoryModel, "Extract")))
218+
CurrentPipeline = default;
219+
}
231220

232-
if (CurrentPipeline is not null)
233-
await LoadPipelineAsync();
221+
if (CurrentPipeline is not null)
222+
await LoadPipelineAsync();
223+
}
234224
}
235225

236226
}

DiffuseApp/DiffuseApp/Views/ImageUpscaleView.xaml.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,21 @@ private bool CanCancel()
208208

209209
protected async void SelectedUpscalerChanged(object sender, PipelineModel pipeline)
210210
{
211-
if (pipeline.UpscaleModel is not null && !pipeline.UpscaleModel.IsValid)
211+
if (pipeline?.UpscaleModel == null)
212212
{
213-
if (!await pipeline.UpscaleModel.DownloadAsync(Path.Combine(Settings.DirectoryModel, "Upscale")))
214-
CurrentPipeline = default;
213+
await UnloadPipelineAsync();
215214
}
215+
else
216+
{
217+
if (pipeline.UpscaleModel is not null && !pipeline.UpscaleModel.IsValid)
218+
{
219+
if (!await pipeline.UpscaleModel.DownloadAsync(Path.Combine(Settings.DirectoryModel, "Upscale")))
220+
CurrentPipeline = default;
221+
}
216222

217-
if (CurrentPipeline is not null)
218-
await LoadPipelineAsync();
223+
if (CurrentPipeline is not null)
224+
await LoadPipelineAsync();
225+
}
219226
}
220227
}
221228
}

0 commit comments

Comments
 (0)