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
|
|
@ -5,16 +5,16 @@
|
|||
<ScrollViewer>
|
||||
<StackPanel Margin="4" Spacing="6">
|
||||
<TextBlock Text="Face Recognition Encoder" FontWeight="Bold" />
|
||||
<TextBlock Text="Esegue il face encoder usando la cartella Destinazione corrente come --images e un file .pkl come --out."
|
||||
<TextBlock Text="Esegue il face encoder usando la cartella Destinazione corrente come --images e genera automaticamente file .pkl e log nella cartella di output scelta."
|
||||
TextWrapping="Wrap" Opacity="0.8" />
|
||||
|
||||
<TextBlock Text="Eseguibile" FontWeight="Bold" Margin="0,4,0,0" />
|
||||
<TextBlock Text="Cartella Face Encoder" FontWeight="Bold" Margin="0,4,0,0" />
|
||||
<Grid ColumnDefinitions="Auto,*,Auto,Auto" ColumnSpacing="6">
|
||||
<TextBlock Grid.Column="0" Text="face_encoder:" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="1" Name="FaceExecutablePathTextBox" Text="{Binding FaceExecutablePath, Mode=TwoWay}" Watermark="C:\\tools\\face_encoder_cpu.exe" />
|
||||
<TextBlock Grid.Column="0" Text="Percorso:" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="1" Name="FaceExecutablePathTextBox" Text="{Binding FaceExecutablePath, Mode=TwoWay}" Watermark="C:\tools\Face_Recognition_Windows" />
|
||||
<Button Grid.Column="2" Name="FaceSelectExecutableButton" Click="SelectFaceExecutable_Click" Width="104" Margin="6,0,0,0">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="6">
|
||||
<iconPacks:PackIconMaterial Kind="FileOutline" Width="14" Height="14" />
|
||||
<iconPacks:PackIconMaterial Kind="FolderOutline" Width="14" Height="14" />
|
||||
<TextBlock Text="Scegli..." />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
|
@ -28,14 +28,24 @@
|
|||
|
||||
<StackPanel Orientation="Horizontal" Spacing="12">
|
||||
<CheckBox Content="Ricorsivo (--recursive)" IsChecked="{Binding FaceRecursive, Mode=TwoWay}" />
|
||||
<CheckBox Content="Includi thumbnail (--include-tn)" IsChecked="{Binding FaceIncludeThumbnails, Mode=TwoWay}" />
|
||||
<CheckBox Content="Upsample (--upsample)" IsChecked="{Binding FaceUpsample, Mode=TwoWay}" />
|
||||
<CheckBox Content="Usa GPU"
|
||||
IsChecked="{Binding UseFaceGpu, Mode=TwoWay}"
|
||||
IsEnabled="{Binding FaceGpuOptionEnabled}" />
|
||||
</StackPanel>
|
||||
<TextBlock Text="Se l'eseguibile termina con _cpu o _gpu, il checkbox GPU cambia automaticamente il file usato. Se non c'e il suffisso, viene trattato come CPU."
|
||||
<TextBlock Text="Seleziona la cartella base di Face Recognition Windows: l'app sceglie automaticamente face_encoder_cpu.exe o face_encoder_gpu.exe in base al checkbox GPU."
|
||||
TextWrapping="Wrap"
|
||||
Opacity="0.75" />
|
||||
|
||||
<Grid ColumnDefinitions="Auto,120,Auto,120,*" ColumnSpacing="6">
|
||||
<TextBlock Grid.Column="0" Text="Parallelismo:" VerticalAlignment="Center" />
|
||||
<ComboBox Grid.Column="1" ItemsSource="{Binding FaceParallelismOptions}" SelectedItem="{Binding FaceParallelism, Mode=TwoWay}" />
|
||||
<TextBlock Grid.Column="2" Text="Min size:" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="3" Text="{Binding FaceMinSize, Mode=TwoWay}" Watermark="35" />
|
||||
<TextBlock Grid.Column="4" Text="Usa --multicore in CPU e --multiprocess in GPU." VerticalAlignment="Center" Opacity="0.75" />
|
||||
</Grid>
|
||||
|
||||
<Grid ColumnDefinitions="Auto,*,Auto,Auto" ColumnSpacing="6">
|
||||
<TextBlock Grid.Column="0" Text="Sorgente:" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="1" Name="FaceDestinationPathTextBox" Text="{Binding DestinationPath, Mode=OneWay}" IsReadOnly="True" />
|
||||
|
|
@ -49,11 +59,11 @@
|
|||
|
||||
<TextBlock Text="Output encodings" FontWeight="Bold" Margin="0,4,0,0" />
|
||||
<Grid ColumnDefinitions="Auto,*,Auto,Auto" ColumnSpacing="6">
|
||||
<TextBlock Grid.Column="0" Text="File out (.pkl):" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="1" Name="FaceOutputFolderTextBox" Text="{Binding FaceOutputFolderPath, Mode=TwoWay}" Watermark="C:\\output\\encodings.pkl" />
|
||||
<Button Grid.Column="2" Name="FaceSelectOutputButton" Click="SelectFaceOutputFile_Click" Width="104" Margin="6,0,0,0">
|
||||
<TextBlock Grid.Column="0" Text="Cartella out:" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Column="1" Name="FaceOutputFolderTextBox" Text="{Binding FaceOutputFolderPath, Mode=TwoWay}" Watermark="C:\output\face_encoder" />
|
||||
<Button Grid.Column="2" Name="FaceSelectOutputButton" Click="SelectFaceOutputFolder_Click" Width="104" Margin="6,0,0,0">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="6">
|
||||
<iconPacks:PackIconMaterial Kind="FileOutline" Width="14" Height="14" />
|
||||
<iconPacks:PackIconMaterial Kind="FolderOutline" Width="14" Height="14" />
|
||||
<TextBlock Text="Scegli..." />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
|
@ -64,9 +74,22 @@
|
|||
</StackPanel>
|
||||
</Button>
|
||||
</Grid>
|
||||
<TextBlock Text="I file vengono creati come face_encodings_yyyyMMdd_HHmmss_nomecartella.pkl e encoder_log_yyyyMMdd_HHmmss_nomecartella.txt."
|
||||
TextWrapping="Wrap"
|
||||
Opacity="0.75" />
|
||||
|
||||
<StackPanel Orientation="Horizontal" Spacing="6" Margin="0,6,0,0">
|
||||
<Button Name="FaceRunButton" Content="Esegui Face Encoder" Command="{Binding StartFaceEncoderCommand}" />
|
||||
<Button Name="FaceRunButton" Command="{Binding StartFaceEncoderCommand}">
|
||||
<StackPanel Orientation="Horizontal" Spacing="8" VerticalAlignment="Center">
|
||||
<ProgressBar Width="18"
|
||||
Height="18"
|
||||
IsIndeterminate="True"
|
||||
IsVisible="{Binding IsFaceEncoderRunning}"
|
||||
ShowProgressText="False"
|
||||
VerticalAlignment="Center" />
|
||||
<TextBlock Text="Esegui Face Encoder" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Content="Stop" Command="{Binding StopFaceEncoderCommand}" />
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding FaceStatusMessage}" />
|
||||
</StackPanel>
|
||||
|
|
@ -77,7 +100,10 @@
|
|||
IsReadOnly="True"
|
||||
AcceptsReturn="True"
|
||||
TextWrapping="Wrap"
|
||||
MinHeight="180" />
|
||||
FontFamily="Cascadia Mono, Consolas, monospace"
|
||||
Height="220"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto" />
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
|
|
|
|||
|
|
@ -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