Skip to content

Commit

Permalink
Merge pull request #44 from lizaalert/dev
Browse files Browse the repository at this point in the history
Dev - 0.2.9 release
  • Loading branch information
gosha20777 authored Sep 12, 2019
2 parents c3e2254 + 660b85c commit 9d0b142
Show file tree
Hide file tree
Showing 20 changed files with 1,172 additions and 1,003 deletions.
8 changes: 8 additions & 0 deletions DataUtils/LaddAugmentor/LaddAugmentor.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>

</Project>
12 changes: 12 additions & 0 deletions DataUtils/LaddAugmentor/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace LaddAugmentor
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
26 changes: 26 additions & 0 deletions DataUtils/LaddGenerator.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaddGenerator", ".\LaddGenerator\LaddGenerator.csproj", "{D452A77C-D639-4376-8372-BA5B8AC67CF4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaddValidator", ".\LaddValidator\LaddValidator.csproj", "{C9A6B61C-8F39-4A32-BDA0-6C248153448E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D452A77C-D639-4376-8372-BA5B8AC67CF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D452A77C-D639-4376-8372-BA5B8AC67CF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D452A77C-D639-4376-8372-BA5B8AC67CF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D452A77C-D639-4376-8372-BA5B8AC67CF4}.Release|Any CPU.Build.0 = Release|Any CPU
{2C83E9CE-CD86-4B8F-AC3A-60CB7ACB9F07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C83E9CE-CD86-4B8F-AC3A-60CB7ACB9F07}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C83E9CE-CD86-4B8F-AC3A-60CB7ACB9F07}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C83E9CE-CD86-4B8F-AC3A-60CB7ACB9F07}.Release|Any CPU.Build.0 = Release|Any CPU
{C9A6B61C-8F39-4A32-BDA0-6C248153448E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9A6B61C-8F39-4A32-BDA0-6C248153448E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9A6B61C-8F39-4A32-BDA0-6C248153448E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9A6B61C-8F39-4A32-BDA0-6C248153448E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
9 changes: 3 additions & 6 deletions DataUtils/LaddGenerator/Annotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,13 @@ public void Normalize()
Ymax = ParseInt(Ymax);
}

private string ParseInt(string str, int maxVal, int minVal = 0)
private string ParseInt(string str)
{
str = str.Split('.').First();
if (int.TryParse(str, out var r))
{
if(r < minVal)
r = minVal;
else if (r > maxVal)
r = maxVal;

if(r < 0)
r = 0;
return $"{r}";
}
throw new Exception();
Expand Down
95 changes: 55 additions & 40 deletions DataUtils/LaddGenerator/ArgsParser.cs
Original file line number Diff line number Diff line change
@@ -1,41 +1,56 @@
using System;
using System.Collections.Generic;

namespace LaddGenerator
{
public class ArgsParser
{
private readonly Dictionary<string, string> _argsKeys;

public ArgsParser(Dictionary<string, string> argsKeys)
{
_argsKeys = argsKeys;
}

public Dictionary<string, string> Parse(string[] args)
{
if (args.Length / 2 != _argsKeys.Count)
{
Console.Write("usage\n");
foreach (var (key, value) in _argsKeys)
{
Console.WriteLine($"\t{key}\t{value}");
}

return null;
}

Dictionary<string, string> result = new Dictionary<string, string>();
foreach (var (key, value) in _argsKeys)
{
for (int i = 0; i < args.Length; i += 2)
{
if(args[i].Contains(key))
result.Add(key.Replace("--", ""), args[i+1]);
}
}

return result;
}
}
using System;
using System.Collections.Generic;

namespace LaddGenerator
{
public class ArgsParser
{
private readonly Dictionary<string, string> _argsKeys;

public ArgsParser(Dictionary<string, string> argsKeys)
{
_argsKeys = argsKeys;
}

public Dictionary<string, string> Parse(string[] args)
{
if (args.Length == 0)
{
List<string> argsList = new List<string>();
Console.Write("usage\n");
foreach (var (key, value) in _argsKeys)
{
Console.WriteLine($"\t{key}\t{value}");
}
for (int i = 0; i < _argsKeys.Count; i++)
{
argsList.AddRange(Console.ReadLine()?.Split(' '));
}

args = argsList.ToArray();
}
else if (args.Length / 2 != _argsKeys.Count)
{
Console.Write("usage\n");
foreach (var (key, value) in _argsKeys)
{
Console.WriteLine($"\t{key}\t{value}");
}

return null;
}

Dictionary<string, string> result = new Dictionary<string, string>();
foreach (var (key, value) in _argsKeys)
{
for (int i = 0; i < args.Length; i += 2)
{
if(args[i].Contains(key))
result.Add(key.Replace("--", ""), args[i+1]);
}
}

return result;
}
}
}
16 changes: 0 additions & 16 deletions DataUtils/LaddGenerator/LaddGenerator.sln

This file was deleted.

5 changes: 3 additions & 2 deletions DataUtils/LaddGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static void Main(string[] args)
try
{
var srcAnnotation = Annotation.ParseFromXml(sfile);
if (!srcAnnotation.Filename.EndsWith(".jpg"))
if (!srcAnnotation.Filename.ToLower().EndsWith(".jpg"))
srcAnnotation.Filename += ".jpg";

var dstAnnotation = new Annotation();
Expand All @@ -72,7 +72,8 @@ static void Main(string[] args)
dstAnnotation.Size = srcAnnotation.Size;
if (dstAnnotation.Objects == null || dstAnnotation.Objects.Count <= 0)
{
throw new Exception("no objects in the image!");
dstAnnotation.Objects = new List<Object>();
//throw new Exception("no objects in the image!");
}
foreach (var obj in dstAnnotation.Objects)
{
Expand Down
56 changes: 56 additions & 0 deletions DataUtils/LaddValidator/ArgsParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;

namespace LaddValidator
{
public class ArgsParser
{
private readonly Dictionary<string, string> _argsKeys;

public ArgsParser(Dictionary<string, string> argsKeys)
{
_argsKeys = argsKeys;
}

public Dictionary<string, string> Parse(string[] args)
{
if (args.Length == 0)
{
List<string> argsList = new List<string>();
Console.Write("usage\n");
foreach (var (key, value) in _argsKeys)
{
Console.WriteLine($"\t{key}\t{value}");
}
for (int i = 0; i < _argsKeys.Count; i++)
{
argsList.AddRange(Console.ReadLine()?.Split(' '));
}

args = argsList.ToArray();
}
else if (args.Length / 2 != _argsKeys.Count)
{
Console.Write("usage\n");
foreach (var (key, value) in _argsKeys)
{
Console.WriteLine($"\t{key}\t{value}");
}

return null;
}

Dictionary<string, string> result = new Dictionary<string, string>();
foreach (var (key, value) in _argsKeys)
{
for (int i = 0; i < args.Length; i += 2)
{
if(args[i].Contains(key))
result.Add(key.Replace("--", ""), args[i+1]);
}
}

return result;
}
}
}
8 changes: 8 additions & 0 deletions DataUtils/LaddValidator/LaddValidator.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>

</Project>
75 changes: 75 additions & 0 deletions DataUtils/LaddValidator/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace LaddValidator
{
class Program
{
private static readonly Dictionary<string, string> _argsKeys = new Dictionary<string, string>()
{
{"--src", "source path"},
{"--val_file", "destination path"},
};

static void Main(string[] args)
{
var parser = new ArgsParser(_argsKeys);
var parsedArgs = parser.Parse(args);
if (parsedArgs == null)
{
return;
}
var splitPatch = parsedArgs["src"] + "ImageSets/Main/";
var valFilePatch = parsedArgs["val_file"];
if (!Directory.Exists(splitPatch))
{
Console.Write("unable to open: " + splitPatch);
return;
}
if (!File.Exists(valFilePatch))
{
Console.Write("unable to open: " + valFilePatch);
return;
}

var valLines = File.ReadLines(valFilePatch).ToList();
var trainLines = File.ReadLines(splitPatch + "train.txt").ToList();
var testLines = File.ReadLines(splitPatch + "test.txt").ToList();
trainLines.AddRange(testLines);

for (int i = 0; i < trainLines.Count; i++)
{
for (int j = 0; j < valLines.Count; j++)
{
if (valLines[j] == trainLines[i])
{
trainLines.RemoveAt(i);
Console.WriteLine($"{valLines[j]} moved to val set");
if(i>0)
i--;
}
}
}
Shuffle(valLines);
File.WriteAllLines(splitPatch+"train.txt", trainLines);
File.WriteAllLines(splitPatch+"trainval.txt", trainLines);
File.WriteAllLines(splitPatch+"test.txt", valLines);
File.WriteAllLines(splitPatch+"val.txt", valLines);
}

private static void Shuffle<T>(IList<T> list)
{
Random rng = new Random();
int n = list.Count;
while (n > 1) {
n--;
int k = rng.Next(n + 1);
T value = list[k];
list[k] = list[n];
list[n] = value;
}
}
}
}
5 changes: 0 additions & 5 deletions RescuerLaApp/Models/Docker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,6 @@ public async Task<bool> Run(string id)
return true;
}
}

var param = new ContainerStartParameters()
{
DetachKeys = "--runtime=nvidia"
};

return await _client.Containers.StartContainerAsync(id, new ContainerStartParameters());
}
Expand Down
4 changes: 2 additions & 2 deletions RescuerLaApp/Models/NeuroModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public async Task<List<BoundBox>> Predict(Frame frame)
var json = JsonConvert.SerializeObject(jsonImg);
var outputText = await _client.PostAsync(json, "image");
var objects = JsonConvert.DeserializeObject<JsonAnnotation>(outputText);
Console.WriteLine(outputText);
if (objects != null || objects.Objects.Count > 0)
{
Console.WriteLine("File {0} contains:", Path.GetFileName(frame.Patch));
foreach (var ooj in objects.Objects)
{
var x1 = ooj.Xmin;
Expand All @@ -87,7 +87,7 @@ public async Task<List<BoundBox>> Predict(Frame frame)
y2-y1,
x2-x1);
list.Add(rect);
Console.WriteLine($">{label}: {score}");
Console.WriteLine("\t{0}: {1:P1}", label, double.Parse(score.Replace('.',',')));
}
}
return list;
Expand Down
2 changes: 1 addition & 1 deletion RescuerLaApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal static class Program
{
private static void Main(string[] args)
{
Console.WriteLine("Lacmus desktop application. Version 0.2.7 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("Lacmus desktop application. Version 0.2.9 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("------------------------------------");
Expand Down
Loading

0 comments on commit 9d0b142

Please sign in to comment.