Skip to content

Commit

Permalink
Merge pull request #113 from lacmus-foundation/dev
Browse files Browse the repository at this point in the history
Dev: Report image processing result #66
  • Loading branch information
gosha20777 authored Aug 17, 2020
2 parents 0879a74 + ae26a1c commit 65d47aa
Show file tree
Hide file tree
Showing 10 changed files with 227 additions and 16 deletions.
29 changes: 16 additions & 13 deletions src/LacmusApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<Company>Lacmus Foundation</Company>
<AssemblyVersion>0.4.2.0</AssemblyVersion>
<FileVersion>0.4.2.0</FileVersion>
<AssemblyVersion>0.4.3.0</AssemblyVersion>
<FileVersion>0.4.3.0</FileVersion>
</PropertyGroup>
<ItemGroup>
<Compile Update="**\*.xaml.cs">
Expand All @@ -14,26 +14,29 @@
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Assets\*" />
<EmbeddedResource Update="Views\BugReportWindow.xaml">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.9.10" />
<PackageReference Include="Avalonia" Version="0.9.12" />
<PackageReference Include="Avalonia.Angle.Natives" Version="2.0.0" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="0.9.10" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="0.9.12" />
<PackageReference Include="Avalonia.Controls.PanAndZoom" Version="2.3.2" />
<PackageReference Include="Avalonia.Desktop" Version="0.9.10" />
<PackageReference Include="Avalonia.Native" Version="0.9.10" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.9.10" />
<PackageReference Include="Avalonia.Desktop" Version="0.9.12" />
<PackageReference Include="Avalonia.Native" Version="0.9.12" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.9.12" />
<PackageReference Include="Avalonia.Skia.Linux.Natives" Version="1.68.0.2" />
<PackageReference Include="Citrus.Avalonia" Version="1.2.4" />
<PackageReference Include="Citrus.Avalonia" Version="1.2.6" />
<PackageReference Include="Docker.DotNet" Version="3.125.2" />
<PackageReference Include="Material.Avalonia" Version="0.9.0" />
<PackageReference Include="MessageBox.Avalonia" Version="0.9.6.1" />
<PackageReference Include="MetadataExtractor" Version="2.3.1" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="3.1.3" />
<PackageReference Include="MetadataExtractor" Version="2.4.3" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="3.1.6" />
<PackageReference Include="NewtonSoft.Json" Version="12.0.3" />
<PackageReference Include="Octokit" Version="0.47.0" />
<PackageReference Include="ReactiveUI.Fody" Version="11.4.1" />
<PackageReference Include="ReactiveUI.Validation" Version="1.4.15" />
<PackageReference Include="Octokit" Version="0.48.0" />
<PackageReference Include="ReactiveUI.Fody" Version="11.5.6" />
<PackageReference Include="ReactiveUI.Validation" Version="1.5.5" />
<PackageReference Include="Serilog" Version="2.9.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
Expand Down
41 changes: 41 additions & 0 deletions src/Services/LocalizationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ [Reactive] public string ModelManager
get { return _modelManager; }
set { this.RaiseAndSetIfChanged(ref _modelManager, value); }
}
private string _bugReport;
[Reactive] public string BugReport
{
get { return _bugReport; }
set { this.RaiseAndSetIfChanged(ref _bugReport, value); }
}
private string _image;
[Reactive] public string Image
{
Expand Down Expand Up @@ -807,6 +813,29 @@ [Reactive] public string SettingsBatchSize

#endregion

#region BUG REPORT WINDOW

private string _labelingWindowCapture;
[Reactive] public string LabelingWindowCapture
{
get { return _labelingWindowCapture; }
set { this.RaiseAndSetIfChanged(ref _labelingWindowCapture, value); }
}
private string _labelingWindowFalsePositive;
[Reactive] public string LabelingWindowFalsePositive
{
get { return _labelingWindowFalsePositive; }
set { this.RaiseAndSetIfChanged(ref _labelingWindowFalsePositive, value); }
}
private string _labelingWindowFalseNegative;
[Reactive] public string LabelingWindowFalseNegative
{
get { return _labelingWindowFalseNegative; }
set { this.RaiseAndSetIfChanged(ref _labelingWindowFalseNegative, value); }
}

#endregion

public LocalizationContext()
{
this.WhenAnyValue(vm=>vm.Language).Subscribe(_=>UpdateText());
Expand Down Expand Up @@ -836,6 +865,7 @@ private void UpdateText()
LoadModel="Load model";
UpdateModel="Update model";
ModelManager="Model manager...";
BugReport = "Send bug report...";
//Image
Image="Image";
PredictAll="Predict All";
Expand Down Expand Up @@ -969,6 +999,11 @@ private void UpdateText()
//ModelManagerApplyButton = "Apply";
//ModelManagerCloseButton = "Close";

//BugReportWindow
LabelingWindowCapture = "By submitting reports on neural network errors, you improve our recognition algorithm. Thank you for helping us develop!\n\nPlease select an error type:";
LabelingWindowFalsePositive = "No person found in the photo (False Negative).";
LabelingWindowFalseNegative = "An object was found in the photo but it is not a person (False Positive).";

OsErrorMesageGPU = "Your OS is not support this ml model type.";
break;
}
Expand All @@ -990,6 +1025,7 @@ private void UpdateText()
LoadModel="Загрузить";
UpdateModel="Обновить";
ModelManager="Менеджер моделей...";
BugReport = "Сообщить об ошибке...";
//Image
Image="Изображение";
PredictAll="Обработать все";
Expand Down Expand Up @@ -1109,6 +1145,11 @@ private void UpdateText()
SettingsPort = "Порт:";
SettingsJWT = "Внешнее использование (включить JVT шифрование)";
SettingsBatchSize = "Число потоков";

//BugReportWindow
LabelingWindowCapture = "Отправляя нам отчеты об ошибках в работе нейронной сети, вы обучаете и улучшаете наш алгоритм распознования! Спасибо что используете Lacmus и помогаете нам развиваться!\n\nПожалуйста выбирете тип ошибки:";
LabelingWindowFalsePositive = "На фото не найден человек (False Negative).";
LabelingWindowFalseNegative = "На фото обнаружен объект, но это не человек (False Positive).";

//Erroes
OsErrorMesageGPU = "Ваша операционная система не поддерживает этот тип ml моделей.";
Expand Down
62 changes: 62 additions & 0 deletions src/ViewModels/BugReportViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Diagnostics;
using System.Reactive;
using System.Runtime.InteropServices;
using Avalonia.Controls;
using LacmusApp.Services;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Serilog;

namespace LacmusApp.ViewModels
{
public class BugReportViewModel : ReactiveObject
{
public BugReportViewModel(Window window, LocalizationContext localizationContext)
{
LocalizationContext = localizationContext;
OpenFalseNegativeCommand = ReactiveCommand.Create(OpenFalseNegative);
OpenFalsePositiveCommand = ReactiveCommand.Create(OpenFalsePositive);
}
[Reactive] public LocalizationContext LocalizationContext { get; set; }
public ReactiveCommand<Unit, Unit> OpenFalseNegativeCommand { get; set; }
public ReactiveCommand<Unit, Unit> OpenFalsePositiveCommand { get; set; }

public void OpenFalseNegative()
{
OpenUrl("https://forms.gle/QbJaqcYvozC1dqTg7");
}
public void OpenFalsePositive()
{
OpenUrl("https://forms.gle/FAGyGsSiFooVt5L89");
}
private void OpenUrl(string url)
{
try
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
//https://stackoverflow.com/a/2796367/241446
using (Process proc = new Process {StartInfo = {UseShellExecute = true, FileName = url}})
{
proc.Start();
}
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Process.Start("x-www-browser", url);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Process.Start("open", url);
}
else
throw new Exception();
}
catch (Exception e)
{
Log.Error(e,$"Unable to ope url {url}.");
}
}
}
}
15 changes: 14 additions & 1 deletion src/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ private void SetupCommand(IObservable<bool> canExecute, IObservable<bool> canSwi
LoadModelCommand = ReactiveCommand.Create(LoadModel, canExecute);
UpdateModelCommand = ReactiveCommand.Create(UpdateModel, canExecute);
OpenModelManagerCommand = ReactiveCommand.Create(OpenModelManager, canExecute);
OpenBugReportCommand = ReactiveCommand.Create(OpenBugReport, canExecute);

NextPageCommand = ReactiveCommand.Create(ShowNextPage);
PreviousPageCommand = ReactiveCommand.Create(ShowPreviousPage);
Expand Down Expand Up @@ -184,6 +185,7 @@ [Reactive] public int TotalPages
public ReactiveCommand<Unit, Unit> LoadModelCommand { get; set; }
public ReactiveCommand<Unit, Unit> UpdateModelCommand { get; set; }
public ReactiveCommand<Unit, Unit> OpenModelManagerCommand { get; set; }
public ReactiveCommand<Unit, Unit> OpenBugReportCommand { get; set; }
public ReactiveCommand<Unit, Unit> SaveAsCommand { get; set; }
public ReactiveCommand<Unit, Unit> FirstPageCommand { get; set; }
public ReactiveCommand<Unit, Unit> PreviousPageCommand { get; set; }
Expand Down Expand Up @@ -336,6 +338,14 @@ public async void OpenModelManager()
_appConfig = await window.ShowResult();
}

public async void OpenBugReport()
{
BugReportWindow window = new BugReportWindow(_themeManager);
var context = new BugReportViewModel(window, LocalizationContext);
window.DataContext = context;
window.Show();
}

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -568,7 +578,10 @@ private void OpenUrl(string url)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Process.Start("cmd", $"/C start {url}");
using (Process proc = new Process {StartInfo = {UseShellExecute = true, FileName = url}})
{
proc.Start();
}
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Expand Down
5 changes: 4 additions & 1 deletion src/ViewModels/MetadataViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ private void OpenUrl(string url)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Process.Start("cmd", $"/C start {url}");
using (Process proc = new Process {StartInfo = {UseShellExecute = true, FileName = url}})
{
proc.Start();
}
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Expand Down
33 changes: 33 additions & 0 deletions src/ViewModels/SettingsWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public SettingsWindowViewModel(SettingsWindow window, LocalizationContext contex
_config = config;
_newConfig = AppConfig.DeepCopy(_config);
_applicationStatusManager = manager;
InitView();

this.WhenAnyValue(x => x.ThemeIndex)
.Skip(1)
Expand Down Expand Up @@ -80,6 +81,38 @@ private void SetupCommands()
UpdateModelStatusCommand = ReactiveCommand.Create(UpdateModelStatus);
OpenModelMnagerCommand = ReactiveCommand.Create(OpenModelManager);
}

private void InitView()
{
switch (LocalizationContext.Language)
{
case Language.English:
LanguageIndex = 0;
break;
case Language.Russian:
LanguageIndex = 1;
break;
}

switch (_settingsThemeManager.CurrentTheme)
{
case ThemeManager.Theme.Citrus:
ThemeIndex = 0;
break;
case ThemeManager.Theme.Rust:
ThemeIndex = 1;
break;
case ThemeManager.Theme.Sea:
ThemeIndex = 2;
break;
case ThemeManager.Theme.Candy:
ThemeIndex = 3;
break;
case ThemeManager.Theme.Magma:
ThemeIndex = 4;
break;
}
}

private async void Apply()
{
Expand Down
35 changes: 35 additions & 0 deletions src/Views/BugReportWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Icon="resm:LacmusApp.Assets.avalonia-logo.ico"
x:Class="LacmusApp.Views.BugReportWindow"
CanResize="True"
Title="Bug Report"
Width="650"
Height="300">

<Grid>
<ScrollViewer HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Hidden">
<Border Classes="Card">
<Grid>
<StackPanel Margin="10, 10">
<TextBlock TextWrapping="Wrap" Classes="Heading" Text="{Binding LocalizationContext.LabelingWindowCapture}" />
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="10" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button Grid.Row="0"
Content="{Binding LocalizationContext.LabelingWindowFalsePositive}"
Command="{Binding OpenFalsePositiveCommand}"/>
<Button Grid.Row="2"
Content="{Binding LocalizationContext.LabelingWindowFalseNegative}"
Command="{Binding OpenFalseNegativeCommand}"/>
</Grid>
</StackPanel>
</Grid>
</Border>
</ScrollViewer>
</Grid>
</Window>
20 changes: 20 additions & 0 deletions src/Views/BugReportWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
using LacmusApp.Managers;
using LacmusApp.ViewModels;
using ReactiveUI;

namespace LacmusApp.Views
{
public class BugReportWindow : ReactiveWindow<BugReportViewModel>
{
public BugReportWindow(ThemeManager themeManager)
{
var localThemeManager = new ThemeManager(this);
localThemeManager.UseTheme(themeManager.CurrentTheme);
this.WhenActivated(disposables => { });
AvaloniaXamlLoader.Load(this);
}
public BugReportWindow() { }
}
}
1 change: 1 addition & 0 deletions src/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<MenuItem Name="mModelLoad" Header="{Binding LocalizationContext.LoadModel}" Command="{Binding LoadModelCommand}"/>
<MenuItem Name="mModelUpdate" Header="{Binding LocalizationContext.UpdateModel}" Command="{Binding UpdateModelCommand}"/>
<MenuItem Name="mModelManager" Header="{Binding LocalizationContext.ModelManager}" Command="{Binding OpenModelManagerCommand}"/>
<MenuItem Name="mBugReport" Header="{Binding LocalizationContext.BugReport}" Command="{Binding OpenBugReportCommand}"/>
</MenuItem>
<MenuItem Name="mImage" Header="{Binding LocalizationContext.Image}">
<MenuItem Name="mImagePredictAll" Header="{Binding LocalizationContext.PredictAll}" Command="{Binding PredictAllCommand}"/>
Expand Down
2 changes: 1 addition & 1 deletion src/Views/ModelManagerWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 5">
<TextBlock Classes="Caption"
Text="{Binding LocalizationContext.MetadataHeader}"/>
Text="{Binding LocalizationContext.WizardThirdModelRepository}"/>
<TextBlock Classes="Caption"
Text="{Binding Repository}"/>
</StackPanel>
Expand Down

0 comments on commit 65d47aa

Please sign in to comment.