Skip to content

Commit dcdf1e8

Browse files
committed
More efficient rendering and smaller base image
1 parent fe85fc6 commit dcdf1e8

File tree

7 files changed

+51
-31
lines changed

7 files changed

+51
-31
lines changed

.DS_Store

0 Bytes
Binary file not shown.

Damselfly.Core/Services/SearchQueryService.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,7 @@ private async Task<SearchResponse> LoadMoreData(SearchQuery query, int first, in
294294

295295
// Set the results on the service property
296296
response.SearchResults = enrichedImages.Select(x => x.ImageId).ToArray();
297-
298-
if( System.Diagnostics.Debugger.IsAttached )
299-
await Task.Delay( 2 * 1000 );
300-
297+
301298
return response;
302299
}
303300

Damselfly.ML.FaceONNX/Damselfly.ML.FaceONNX.csproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@
2424

2525
<!-- Remove once ONNX team fix the bug -->
2626
<Target Name="CustomAfterBuild" AfterTargets="AfterBuild" Condition="('$(IsWindows)'!='true')">
27-
<Message Importance="High" Text="Delete unnecessary onnx dlls" />
28-
<ItemGroup>
29-
<FilesToDeleteInBuild Include="$(TargetDir)onnxruntime*.dll"/>
30-
</ItemGroup>
31-
<Delete Files="@(FilesToDeleteInBuild)" />
27+
<Message Importance="High" Text="Delete unnecessary ONNX DLLs from build" />
28+
<ItemGroup>
29+
<FilesToDeleteInBuild Include="$(TargetDir)onnxruntime*.dll"/>
30+
</ItemGroup>
31+
<Delete Files="@(FilesToDeleteInBuild)" />
3232
</Target>
3333

3434
<!-- Remove once ONNX team fix the bug -->
3535
<Target Name="CustomAfterPublish" AfterTargets="AfterPublish" Condition="('$(IsWindows)'!='true')">
36-
<Message Importance="High" Text="Delete unnecessary onnx dlls" />
37-
<ItemGroup>
38-
<FilesToDeleteInPublish Include="$(PublishDir)onnxruntime*.dll"/>
39-
</ItemGroup>
40-
<Delete Files="@(FilesToDeleteInPublish)" />
36+
<Message Importance="High" Text="Delete unnecessary ONNX DLLs from publish" />
37+
<ItemGroup>
38+
<FilesToDeleteInPublish Include="$(PublishDir)onnxruntime*.dll"/>
39+
</ItemGroup>
40+
<Delete Files="@(FilesToDeleteInPublish)" />
4141
</Target>
4242
</Project>

Damselfly.ML.ObjectDetection.ML/Damselfly.ML.ObjectDetection.csproj

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@
3434
</ItemGroup>
3535

3636
<PropertyGroup>
37-
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
37+
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
3838
</PropertyGroup>
3939

4040
<!-- Remove once ONNX team fix the bug -->
4141
<Target Name="CustomAfterBuild" AfterTargets="AfterBuild" Condition="('$(IsWindows)'!='true')">
42-
<Message Importance="High" Text="Delete unnecessary onnx dlls" />
43-
<ItemGroup>
44-
<FilesToDeleteInBuild Include="$(TargetDir)onnxruntime*.dll"/>
45-
</ItemGroup>
46-
<Delete Files="@(FilesToDeleteInBuild)" />
42+
<Message Importance="High" Text="Delete unnecessary ONNX DLLs from build" />
43+
<ItemGroup>
44+
<FilesToDeleteInBuild Include="$(TargetDir)onnxruntime*.dll"/>
45+
</ItemGroup>
46+
<Delete Files="@(FilesToDeleteInBuild)" />
4747
</Target>
4848

4949
<!-- Remove once ONNX team fix the bug -->
5050
<Target Name="CustomAfterPublish" AfterTargets="AfterPublish" Condition="('$(IsWindows)'!='true')">
51-
<Message Importance="High" Text="Delete unnecessary onnx dlls" />
52-
<ItemGroup>
53-
<FilesToDeleteInPublish Include="$(PublishDir)onnxruntime*.dll"/>
54-
</ItemGroup>
55-
<Delete Files="@(FilesToDeleteInPublish)" />
51+
<Message Importance="High" Text="Delete unnecessary ONNX DLLs from publish" />
52+
<ItemGroup>
53+
<FilesToDeleteInPublish Include="$(PublishDir)onnxruntime*.dll"/>
54+
</ItemGroup>
55+
<Delete Files="@(FilesToDeleteInPublish)" />
5656
</Target>
5757
</Project>

Damselfly.Web.Client/Components/ImageBrowser/ImageGrid.razor

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,20 @@
9494
bool endOfImages = false;
9595
string toastClass = string.Empty;
9696
private ScrollMonitor ScrollMonitor;
97+
CancellationTokenSource cancelTokenSource = new();
98+
CancellationToken? token = null;
9799

98100
[Parameter] public GridImageSize CurrentGridSize { get; set; }
99101

100102
private bool NoResultsFound { get; set; } = true;
101103

104+
protected override void OnInitialized()
105+
{
106+
token = cancelTokenSource.Token;
107+
108+
base.OnInitialized();
109+
}
110+
102111
async Task AddGroupToBasket(ImageGrouping grouping)
103112
{
104113
var imageIds = grouping.Images.Select(x => x.ImageId).ToList();
@@ -199,7 +208,7 @@
199208
if ( initialLoadCount > searchService.SearchResults.Count )
200209
await searchService.LoadMore(initialLoadCount);
201210
else
202-
await AddImagesToGrid(true);
211+
await AddImagesToGrid(true, cancelTokenSource.Token);
203212

204213
await JsRuntime.InvokeVoidAsync("InfiniteScroll.Init", "scroll-area", "list-end", DotNetObjectReference.Create(this));
205214
}
@@ -235,7 +244,12 @@
235244
// If we've tried to load data and there isn't any more, show the toast.
236245
toastClass = endOfImages ? "show" : string.Empty;
237246

238-
_ = AddImagesToGrid(response.MoreDataAvailable);
247+
// Cancel the old request, and start a new one
248+
cancelTokenSource.Cancel();
249+
cancelTokenSource.Dispose();
250+
cancelTokenSource = new CancellationTokenSource();
251+
252+
_ = AddImagesToGrid(response.MoreDataAvailable, cancelTokenSource.Token);
239253
}
240254

241255
protected void SearchQueryChanged()
@@ -260,16 +274,25 @@
260274
await searchService.LoadMore();
261275
}
262276

263-
private async Task AddImagesToGrid(bool moreDataAvailable)
277+
private async Task AddImagesToGrid(bool moreDataAvailable, CancellationToken token)
264278
{
265279
NoResultsFound = true;
266280

267281
if ( searchService.SearchResults.Any() )
268282
{
269283
NoResultsFound = false;
270284

271-
foreach( var set in searchService.SearchResults.Chunk(25) )
285+
// Be careful, as searchResults could change underneath us....
286+
var chunks = searchService.SearchResults
287+
.Chunk(25)
288+
.ToList();
289+
290+
foreach( var set in chunks )
272291
{
292+
// Another refresh, hot on our heels, is cancelling this one
293+
if( token.IsCancellationRequested )
294+
return;
295+
273296
StateHasChanged();
274297

275298
var toAdd = set.ExceptBy(gridImages.Select(x => x.ImageId), x => x).ToList();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
const CACHE_VERSION='4.2.1-20241230153611'
1+
const CACHE_VERSION='4.2.1-20241230223619'

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG BASE_IMAGE=webreaper/damselfly-base:1.9.4
1+
ARG BASE_IMAGE=webreaper/damselfly-base:2.0.0
22

33
FROM $BASE_IMAGE as final
44

0 commit comments

Comments
 (0)