feat: Add face encoder settings including GPU support, parallelism, and thumbnail options
This commit is contained in:
parent
d6b778a648
commit
25fdb82d2f
9 changed files with 595 additions and 136 deletions
|
|
@ -1,7 +1,9 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.Threading;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
|
|
@ -9,9 +11,46 @@ namespace ImageCatalog_2.AvaloniaViews;
|
|||
|
||||
public partial class FaceAiTabView : Avalonia.Controls.UserControl
|
||||
{
|
||||
private INotifyPropertyChanged? _faceAiPropertySource;
|
||||
|
||||
public FaceAiTabView()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContextChanged += OnDataContextChanged;
|
||||
}
|
||||
|
||||
private void OnDataContextChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (_faceAiPropertySource is not null)
|
||||
{
|
||||
_faceAiPropertySource.PropertyChanged -= OnFaceAiPropertyChanged;
|
||||
}
|
||||
|
||||
_faceAiPropertySource = DataContext as INotifyPropertyChanged;
|
||||
if (_faceAiPropertySource is not null)
|
||||
{
|
||||
_faceAiPropertySource.PropertyChanged += OnFaceAiPropertyChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnFaceAiPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (!string.Equals(e.PropertyName, nameof(DataModel.FaceCommandOutput), StringComparison.Ordinal))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var outputBox = this.FindControl<Avalonia.Controls.TextBox>("FaceOutputTextBox");
|
||||
if (outputBox is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
var textLength = outputBox.Text?.Length ?? 0;
|
||||
outputBox.CaretIndex = textLength;
|
||||
});
|
||||
}
|
||||
|
||||
private async void SelectFaceExecutable_Click(object? sender, RoutedEventArgs e)
|
||||
|
|
@ -29,19 +68,14 @@ public partial class FaceAiTabView : Avalonia.Controls.UserControl
|
|||
return;
|
||||
}
|
||||
|
||||
var files = await storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
var folders = await storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
{
|
||||
Title = "Seleziona face_encoder_cpu.exe o face_encoder_gpu.exe",
|
||||
FileTypeFilter =
|
||||
[
|
||||
new FilePickerFileType("Eseguibile") { Patterns = ["*.exe"] },
|
||||
new FilePickerFileType("Tutti i file") { Patterns = ["*.*"] }
|
||||
]
|
||||
Title = "Seleziona la cartella Face Recognition Windows"
|
||||
});
|
||||
|
||||
if (files.Count > 0)
|
||||
if (folders.Count > 0)
|
||||
{
|
||||
executableBox.Text = files[0].Path.LocalPath;
|
||||
executableBox.Text = folders[0].Path.LocalPath;
|
||||
if (DataContext is DataModel model)
|
||||
{
|
||||
model.FaceExecutablePath = executableBox.Text;
|
||||
|
|
@ -49,7 +83,7 @@ public partial class FaceAiTabView : Avalonia.Controls.UserControl
|
|||
}
|
||||
}
|
||||
|
||||
private async void SelectFaceOutputFile_Click(object? sender, RoutedEventArgs e)
|
||||
private async void SelectFaceOutputFolder_Click(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var outputBox = this.FindControl<Avalonia.Controls.TextBox>("FaceOutputFolderTextBox");
|
||||
if (outputBox is null)
|
||||
|
|
@ -64,21 +98,14 @@ public partial class FaceAiTabView : Avalonia.Controls.UserControl
|
|||
return;
|
||||
}
|
||||
|
||||
var files = await storageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
var folders = await storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
{
|
||||
Title = "Seleziona file output encodings (.pkl)",
|
||||
SuggestedFileName = "encodings.pkl",
|
||||
DefaultExtension = "pkl",
|
||||
FileTypeChoices =
|
||||
[
|
||||
new FilePickerFileType("Pickle file") { Patterns = ["*.pkl"] }
|
||||
],
|
||||
ShowOverwritePrompt = true
|
||||
Title = "Seleziona la cartella output per encodings e log"
|
||||
});
|
||||
|
||||
if (files is not null)
|
||||
if (folders.Count > 0)
|
||||
{
|
||||
outputBox.Text = files.Path.LocalPath;
|
||||
outputBox.Text = folders[0].Path.LocalPath;
|
||||
if (DataContext is DataModel model)
|
||||
{
|
||||
model.FaceOutputFolderPath = outputBox.Text;
|
||||
|
|
@ -100,6 +127,12 @@ public partial class FaceAiTabView : Avalonia.Controls.UserControl
|
|||
return;
|
||||
}
|
||||
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
OpenInExplorer(path);
|
||||
return;
|
||||
}
|
||||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
OpenInExplorer(path);
|
||||
|
|
@ -124,6 +157,12 @@ public partial class FaceAiTabView : Avalonia.Controls.UserControl
|
|||
return;
|
||||
}
|
||||
|
||||
if (Directory.Exists(outputPath))
|
||||
{
|
||||
OpenInExplorer(outputPath);
|
||||
return;
|
||||
}
|
||||
|
||||
if (File.Exists(outputPath))
|
||||
{
|
||||
OpenInExplorer(outputPath);
|
||||
|
|
@ -148,6 +187,12 @@ public partial class FaceAiTabView : Avalonia.Controls.UserControl
|
|||
return;
|
||||
}
|
||||
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
OpenInExplorer(path);
|
||||
return;
|
||||
}
|
||||
|
||||
var directory = Path.GetDirectoryName(path);
|
||||
OpenInExplorer(string.IsNullOrWhiteSpace(directory) ? path : directory);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue