Skip to content

Commit

Permalink
Merge pull request #32 from lizaalert/dev
Browse files Browse the repository at this point in the history
Dev 0.2.6 release
  • Loading branch information
gosha20777 authored Aug 14, 2019
2 parents 1f91bbe + 07ca604 commit 7e9b533
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 25 deletions.
85 changes: 70 additions & 15 deletions ResNet50RetinaNet-Image.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions RescuerLaApp/Models/Frame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public List<BoundBox> Rectangles
}
public int Width { get; private set; }
public int Height { get; private set; }

public bool IsVisible { get; set; } = false;

public delegate void MethodContainer();

Expand Down
4 changes: 3 additions & 1 deletion RescuerLaApp/Models/NeuroModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
Expand Down Expand Up @@ -162,9 +163,10 @@ private async Task<int> GetCurrentTag()
var maxTag = 1;
foreach (var t in tags)
{
if (int.TryParse(t, out var tag))
if (int.TryParse(t.Split(':').Last(), out var tag))
maxTag = Math.Max(maxTag, tag);
}
Console.WriteLine(maxTag);
return maxTag;
}

Expand Down
4 changes: 4 additions & 0 deletions RescuerLaApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ internal static class Program
{
private static void Main(string[] args)
{
Console.WriteLine("Lacmus desktop application. Version 0.2.6 alpha. \nCopyright (c) 2019 Georgy Perevozghikov <[email protected]>\nGithub page: https://github.com/lizaalert/lacmus/.\nProvided by Yandex Cloud: https://cloud.yandex.com/.");
Console.WriteLine("This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.");
Console.WriteLine("This is free software, and you are welcome to redistribute it\nunder certain conditions; type `show c' for details.");
Console.WriteLine("------------------------------------");
BuildAvaloniaApp().Start<MainWindow>(() => new MainWindowViewModel());
}

Expand Down
40 changes: 33 additions & 7 deletions RescuerLaApp/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class MainWindowViewModel : ReactiveObject
{
private int _frameLoadProgressIndex;
private NeuroModel _model = null;
private List<Frame> _frames = new List<Frame>();

public MainWindowViewModel()
{
Expand All @@ -34,6 +35,10 @@ public MainWindowViewModel()
var canGoBack = this
.WhenAnyValue(x => x.SelectedIndex)
.Select(index => index > 0);

var canExecute = this
.WhenAnyValue(x => x.Status)
.Select(status => status.Status != Enums.Status.Working);

// The bound button will stay disabled, when
// there are no frames before the current one.
Expand All @@ -44,11 +49,12 @@ public MainWindowViewModel()
// Add here newer commands
IncreaseCanvasCommand = ReactiveCommand.Create(IncreaseCanvas);
ShrinkCanvasCommand = ReactiveCommand.Create(ShrinkCanvas);
PredictAllCommand = ReactiveCommand.Create(PredictAll);
OpenFileCommand = ReactiveCommand.Create(OpenFile);
SaveAllCommand = ReactiveCommand.Create(SaveAll);
LoadModelCommand = ReactiveCommand.Create(LoadModel);
UpdateModelCommand = ReactiveCommand.Create(UpdateModel);
PredictAllCommand = ReactiveCommand.Create(PredictAll, canExecute);
OpenFileCommand = ReactiveCommand.Create(OpenFile, canExecute);
SaveAllCommand = ReactiveCommand.Create(SaveAll, canExecute);
LoadModelCommand = ReactiveCommand.Create(LoadModel, canExecute);
UpdateModelCommand = ReactiveCommand.Create(UpdateModel, canExecute);
ShowPerestriansCommand = ReactiveCommand.Create(ShowPedestrians, canExecute);
}

public void UpdateFramesRepo()
Expand Down Expand Up @@ -76,12 +82,14 @@ public void UpdateFramesRepo()
[Reactive] public double CanvasHeight { get; set; } = 500;

[Reactive] public int SelectedIndex { get; set; } = 0;

[Reactive] public List<Frame> Frames { get; set; } = new List<Frame>();

[Reactive] public AppStatusInfo Status { get; set; } = new AppStatusInfo { Status = Enums.Status.Ready };

[Reactive] public ImageBrush ImageBrush { get; set; } = new ImageBrush { Stretch = Stretch.Uniform };

[Reactive] public bool IsShowPedestrians { get; set; } = false;

public ReactiveCommand<Unit, Unit> PredictAllCommand { get; }

Expand All @@ -100,9 +108,23 @@ public void UpdateFramesRepo()
public ReactiveCommand<Unit, Unit> LoadModelCommand { get; }

public ReactiveCommand<Unit, Unit> UpdateModelCommand { get; }

public ReactiveCommand<Unit, Unit> ShowPerestriansCommand { get; }

#endregion

private void ShowPedestrians()
{
if (IsShowPedestrians)
{
Frames = Frames.FindAll(x => x.IsVisible);
}
else
{
Frames = new List<Frame>(_frames);
}
}

private async void LoadModel()
{
Status = new AppStatusInfo()
Expand Down Expand Up @@ -195,8 +217,11 @@ private async void PredictAll()
Status = Enums.Status.Ready
};
}
}

if (frame.Rectangles.Count > 0)
frame.IsVisible = true;
}
_frames = new List<Frame>(Frames);
await _model.Stop();
UpdateUi();
}
Expand Down Expand Up @@ -257,6 +282,7 @@ private async void OpenFile()
SelectedIndex = 0;
UpdateFramesRepo();
UpdateUi();
_frames = new List<Frame>(Frames);
}
catch (Exception ex)
{
Expand Down
4 changes: 2 additions & 2 deletions RescuerLaApp/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
</ListBox>

<StackPanel Grid.Column="0" Grid.Row="1" Orientation="Horizontal" Background="White">
<CheckBox Name="cbShowAll" Content="Show all" Margin="5,0,2.5,0"/>
<CheckBox Name="cbShowIcons" Content="Show icons" Margin="5,0,2.5,0"/>
<CheckBox Name="cbShowPedestrians" Content="Show pedestrians" Margin="5,0,2.5,0"
IsChecked="{Binding IsShowPedestrians}" Command="{Binding ShowPerestriansCommand}"/>
</StackPanel>
</Grid>
<ScrollViewer Grid.Column="1" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
Expand Down

0 comments on commit 7e9b533

Please sign in to comment.