Skip to content
Permalink
Browse files

Merge pull request #397 from hcmlab/develop

Develop
  • Loading branch information...
tobiasbaur committed Mar 4, 2019
2 parents c83ec9d + e831414 commit 2d70bb5ac1974449996d8dc3cd6cbda83968bea1
Showing with 1,835 additions and 424 deletions.
  1. +11 −1 App/MainWindow.xaml.cs
  2. +4 −2 Controls/Annotation/AnnoTier.cs
  3. +1 −0 Controls/MainControl.xaml
  4. +5 −2 Controls/MainHandler.cs
  5. +4 −2 Controls/MainHandlerAnnotation.cs
  6. +2 −2 Controls/MainHandlerCML.cs
  7. +98 −90 Controls/MainHandlerDownload.cs
  8. +232 −21 Controls/MainHandlerExplanation.cs
  9. +50 −2 Controls/MainHandlerKey.cs
  10. +1 −1 Controls/MainHandlerMedia.cs
  11. +6 −3 Controls/MainHandlerPlay.cs
  12. +25 −9 Controls/Other/ExplanationWindow.xaml
  13. +130 −1 Controls/Other/ExplanationWindow.xaml.cs
  14. +120 −0 Controls/Other/ExplanationWindowInnvestigate.xaml
  15. +204 −0 Controls/Other/ExplanationWindowInnvestigate.xaml.cs
  16. +4 −0 Controls/Other/Settings.xaml
  17. +7 −0 Controls/Other/Settings.xaml.cs
  18. +94 −40 Database/DatabaseCMLTrainAndPredictWindow.xaml.cs
  19. +24 −0 Properties/Settings.Designer.cs
  20. +6 −0 Properties/Settings.settings
  21. +219 −0 PythonScripts/ImageExplainerInnvestigate.py
  22. +39 −1 PythonScripts/ImageExplainerLime.py
  23. BIN References/WPFMediaKit.dll
  24. +3 −0 Types/MediaKit.cs
  25. +38 −26 Types/Skeleton.cs
  26. +6 −0 app.config
  27. BIN bin/ActiveMQSender.dll
  28. BIN bin/OSCSender.dll
  29. +219 −0 bin/PythonScripts/ImageExplainerInnvestigate.py
  30. +39 −1 bin/PythonScripts/ImageExplainerLime.py
  31. BIN bin/UdpSender.dll
  32. +3 −3 bin/cml/models/templates/discrete/video/keras/db_handler.py
  33. +115 −144 bin/cml/models/templates/discrete/video/keras/interface.py
  34. +1 −1 bin/cml/models/templates/discrete/video/keras/keras_vgg_face.option
  35. +5 −6 bin/cml/models/templates/discrete/video/keras/keras_vgg_face.py
  36. +1 −0 bin/cml/models/templates/discrete/video/keras/logs/run_tensorboard.cmd
  37. +112 −52 bin/cml/models/templates/discrete/video/keras/nova_data_generator.py
  38. BIN bin/nova.exe
  39. +0 −7 bin/requirements-nogpu.txt
  40. +0 −7 bin/requirements.txt
  41. BIN bin/ssiliblinear.dll
  42. BIN bin/ssipython.dll
  43. BIN bin/updater.exe
  44. +7 −0 nova.csproj
@@ -111,7 +111,17 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs
{
e.Cancel = true;
}

try
{
var dir = new DirectoryInfo(Path.GetDirectoryName(Properties.Settings.Default.CMLTempTrainerPath));
foreach (var file in dir.EnumerateFiles(Path.GetFileName(Properties.Settings.Default.CMLTempTrainerPath) + "latestcmlmodel*"))
{
file.Delete();
}
}
catch { }


}
}
}
@@ -329,7 +329,7 @@ public AnnoTier(AnnoList anno)

if (!init)
{
yPos = yPos = (numberOfLevels - ((int)(numberOfLevels / 2) * fac)) * segmentHeight;
yPos = (numberOfLevels - ((int)(numberOfLevels / 2) * fac)) * segmentHeight;
init = true;
}

@@ -375,6 +375,8 @@ private void UdpateContinuousPosition()

double normal = 1.0 - (yPos / this.ActualHeight);
double normalized = (normal * range) + this.AnnoList.Scheme.MinScore;
//TODO fix for very small numbers
if (normalized < 1.1102230246251565E-15 && normalized > -1.1102230246251565E-15) normalized = 0;

continuousTierEllipse.Height = this.ActualHeight / 10;
continuousTierEllipse.Width = continuousTierEllipse.Height;
@@ -415,7 +417,7 @@ public void continuousSegmentDown()

double step = fac * segmentHeight;
yPos = (yPos + step <= this.ActualHeight) ? yPos + step : yPos;
if (yPos + step <= this.ActualHeight) level--;
level--;
}

public void continuousSegmentToPosition(int position)
@@ -83,6 +83,7 @@

<MenuItem Header="XAI" Name="XAIMenu">
<MenuItem Header="LimeExplainer" Name="explanationWindow"/>
<MenuItem Header="InnvestigateExplainer" Name="explanationWindowInnvestigate"></MenuItem>
</MenuItem>

<MenuItem Header="?">
@@ -16,9 +16,9 @@ public partial class MainHandler
{

//Config
public static string BuildVersion = "1.0.4.0";
public static string BuildVersion = "1.0.5.1";
public static MEDIABACKEND MediaBackend = MEDIABACKEND.MEDIAKIT;
public static bool ENABLE_PYTHON = true;
public static bool ENABLE_PYTHON = Properties.Settings.Default.EnablePython;

private static Timeline timeline = null;

@@ -211,6 +211,7 @@ public MainHandler(MainControl view)
//PYTHON
if(ENABLE_PYTHON) startExplainableThread();
control.explanationWindow.Click += explanationWindow_Click;
control.explanationWindowInnvestigate.Click += explanationWindowInnvestigate_Click;
control.XAIMenu.Visibility = control.updatePythonMenu.Visibility = (MainHandler.ENABLE_PYTHON ? Visibility.Visible : Visibility.Collapsed);


@@ -566,6 +567,8 @@ private void showSettings()
Properties.Settings.Default.ContinuousHotkeysNumber = int.Parse(s.ContinuousHotkeyLevels());
Properties.Settings.Default.DatabaseAskBeforeOverwrite = s.DBAskforOverwrite();
Properties.Settings.Default.DrawVideoWavform = s.DrawvideoWavform();
Properties.Settings.Default.EnablePython = s.EnablePython();

Properties.Settings.Default.Save();


@@ -606,10 +606,12 @@ private void annoList_SelectionChanged(object sender, SelectionChangedEventArgs
{
AnnoListItem item = (AnnoListItem)grid.SelectedItem;
control.annoListControl.editComboBox.SelectedItem = item.Label;

double samplerate = MainHandler.getMaxVideoSampleRate();
double offset = (1.0f / samplerate);
Time.CurrentPlayPosition = item.Start;

mediaList.Move(item.Start);

mediaList.Move(item.Start+ offset);
moveSignalCursor(item.Start);

if (item.Start >= timeline.SelectionStop)
@@ -88,7 +88,7 @@ private void runCMLProcess(string tool, string options)
private string runCMLTool(string tool, string mode, List<object> parameters, Dictionary<string,object> arguments, string logName)
{
string result = "";
string logPath = AppDomain.CurrentDomain.BaseDirectory + "\\" + logName + ".log";
string logPath = AppDomain.CurrentDomain.BaseDirectory + logName + ".log";

File.Delete(logPath);

@@ -203,7 +203,7 @@ public string CMLTrainModel(string templatePath, string trainerPath, string data
parameters.Add("\"" + trainerPath + "\"");

Dictionary <string, object> arguments = new Dictionary<string, object>();
if (multisessionpath == null) arguments["list"] = sessions;
arguments["list"] = sessions;
arguments["left"] = leftContext;
arguments["right"] = rightContext;
arguments["balance"] = balance;
@@ -503,151 +503,159 @@ private void GetPython()
try
{


webClient.DownloadFile("https://www.python.org/ftp/python/3.6.7/python-3.6.7-embed-amd64.zip", "python.zip");
System.IO.Compression.ZipFile.ExtractToDirectory("python.zip", "python");
File.Delete("python.zip");
System.IO.Compression.ZipFile.ExtractToDirectory("python/python36.zip", "python/python36");
File.Delete("python/python36.zip");
}
catch (Exception e)
{
Console.WriteLine("python is already downloaded and extracted");
}
}
catch (Exception e)
{
Console.WriteLine("python is already downloaded and extracted");
}

string path = AppDomain.CurrentDomain.BaseDirectory + "python\\python36._pth";
string path = AppDomain.CurrentDomain.BaseDirectory + "python\\python36._pth";

using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine(".");
sw.WriteLine(".\\DLLs");
sw.WriteLine(".\\lib");
sw.WriteLine(".\\lib\\plat-win");
sw.WriteLine(".\\lib\\site-packages");
sw.WriteLine(".\\python36");
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine(".");
sw.WriteLine(".\\DLLs");
sw.WriteLine(".\\lib");
sw.WriteLine(".\\lib\\plat-win");
sw.WriteLine(".\\lib\\site-packages");
sw.WriteLine(".\\python36");

}
}

webClient.DownloadFile("https://bootstrap.pypa.io/get-pip.py", "python/get-pip.py");
webClient.DownloadFile("https://bootstrap.pypa.io/get-pip.py", "python/get-pip.py");



string cudapath = Environment.GetEnvironmentVariable("CUDA_PATH", EnvironmentVariableTarget.Machine);

string[] requirements = {

"python/toolz-0.9.0-py2.py3-none-any.whl",
"python/termcolor-1.1.0-py2.py3-none-any.whl",
"python/future-0.17.0-py3-none-any.whl",
"keras-vggface==0.5",
"tensorflow-gpu==1.10.0",
"tensorflow-gpu==1.12.0",
"imageio==2.3.0",
"h5py==2.8.0",
"matplotlib==2.2.3",
"https://github.com/albermax/innvestigate/archive/1.0.7.tar.gz",
"lime==0.1.1.31",
"numpy==1.14.0",
"scipy==1.1.0",
"pymongo==3.7.2",
"scikit_image==0.14.0",
"Pillow==5.4.1"

"Pillow==5.4.1",
"opencv-python==4.0.0.21"


};


if (cudapath != null)
{
{
System.IO.File.WriteAllLines("requirements.txt", requirements);

System.IO.File.WriteAllLines("requirements.txt", requirements);
}
else
}
else
{
MessageBoxResult mb = MessageBox.Show("No CUDA installation found, loading tensorflow without GPU support.", "Attention", MessageBoxButton.YesNo);
if (mb == MessageBoxResult.No)
{
MessageBoxResult mb = MessageBox.Show("No CUDA installation found, loading tensorflow without GPU support.", "Attention", MessageBoxButton.YesNo);
if(mb == MessageBoxResult.No)
{
Directory.Delete(AppDomain.CurrentDomain.BaseDirectory + "\\python");
return;
}
Directory.Delete(AppDomain.CurrentDomain.BaseDirectory + "\\python");
return;
}

requirements[3] = "tensorflow==1.12.0";

requirements[1] = "tensorflow==1.10.0";

System.IO.File.WriteAllLines("requirements.txt", requirements);
}



Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Normal;
startInfo.FileName = "\"" + AppDomain.CurrentDomain.BaseDirectory + "python\\python.exe" + "\"";
startInfo.Arguments = "\"" + AppDomain.CurrentDomain.BaseDirectory + "python\\get-pip.py" + "\"";
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
process.Close();


Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Normal;
startInfo.FileName = "\""+AppDomain.CurrentDomain.BaseDirectory + "python/python.exe"+"\"";
startInfo.Arguments = "\"" + AppDomain.CurrentDomain.BaseDirectory + "python/get-pip.py"+ "\"";
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
string sitepackagepath = Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + "python\\Lib\\site-packages");

//var current = Environment.GetEnvironmentVariable("PYTHONPATH", EnvironmentVariableTarget.User);
//var pythonpath = $"{sitepackagepath}";
//Environment.SetEnvironmentVariable("PYTHONPATH", pythonpath, EnvironmentVariableTarget.User);

string temppythonpath = Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + "python\\Lib\\site-packages");
var current = Environment.GetEnvironmentVariable("PYTHONPATH", EnvironmentVariableTarget.User);
if (current == "")
{
var pythonpath = $"{temppythonpath}";
Environment.SetEnvironmentVariable("PYTHONPATH", pythonpath, EnvironmentVariableTarget.User);
}
else if(current != temppythonpath)
{
var pythonpath = $"{temppythonpath};{Environment.GetEnvironmentVariable("PYTHONPATH", EnvironmentVariableTarget.User)}";
Environment.SetEnvironmentVariable("PYTHONPATH", pythonpath, EnvironmentVariableTarget.User);
}


//Install two wheels for broken pip install files on embedded python. Credit to: Christoph Gohlke https://www.lfd.uci.edu/~gohlke/pythonlibs/. Mirrored on NOVA public git.

process = new Process();
startInfo.FileName = "\"" + AppDomain.CurrentDomain.BaseDirectory + "python\\python" + "\"";
startInfo.Arguments = "-m easy_install termcolor toolz";
process.StartInfo = startInfo;
process.StartInfo.ErrorDialog = true;
process.Start();
process.WaitForExit();


// url = "https://github.com/hcmlab/ssi/blob/master/plugins/ffmpeg/bin/x64/ffmpeg.exe?raw=true";
//Client = new WebClient();
//Client.DownloadFile(url, AppDomain.CurrentDomain.BaseDirectory + "ffprobe.exe");
string urltoolz = "https://github.com/hcmlab/nova/raw/master/packages/python-fixes/toolz-0.9.0-py2.py3-none-any.whl";
string urltermcolor = "https://github.com/hcmlab/nova/raw/master/packages/python-fixes/termcolor-1.1.0-py2.py3-none-any.whl";
string urlfuture = "https://github.com/hcmlab/nova/raw/master/packages/python-fixes/future-0.17.0-py3-none-any.whl";
string urltkinderfix = "https://github.com/hcmlab/nova/raw/master/packages/python-fixes/tkinterfix.zip";

WebClient Client = new WebClient();
Client.DownloadFile(urltoolz, Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + "python\\") + "toolz-0.9.0-py2.py3-none-any.whl");
Client.DownloadFile(urltermcolor, Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + "python\\") + "termcolor-1.1.0-py2.py3-none-any.whl");
Client.DownloadFile(urlfuture, Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + "python\\") + "future-0.17.0-py3-none-any.whl");
Client.DownloadFile(urltkinderfix, Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + "python\\") + "tkinterfix.zip");

process = new Process();
startInfo.FileName = "\"" + AppDomain.CurrentDomain.BaseDirectory + "python\\python" + "\"";
startInfo.Arguments = "-m pip install -r requirements.txt --no-warn-script-location";
process.StartInfo = startInfo;
process.StartInfo.ErrorDialog = true;
process.Start();
process.WaitForExit();
startInfo = new ProcessStartInfo();
startInfo.FileName = "\"" + AppDomain.CurrentDomain.BaseDirectory + "python\\python.exe" + "\"";
startInfo.Arguments = "-m pip install -r requirements.txt --no-warn-script-location";
process.StartInfo = startInfo;
process.StartInfo.ErrorDialog = true;
process.Start();
process.WaitForExit();
process.Close();


//Temporary FIX for VGG FACE latest Keras version bug
string url = "https://raw.githubusercontent.com/hcmlab/nova/master/packages/python-fixes/vggface-fix.py";
WebClient Client = new WebClient();
Client.DownloadFile(url, temppythonpath + "\\keras_vggface\\models.py");
File.Delete(Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + "python\\") + "toolz-0.9.0-py2.py3-none-any.whl");
File.Delete(Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + "python\\") + "termcolor-1.1.0-py2.py3-none-any.whl");


//Temporary FIX for missing TERMCOLOR
url = "https://raw.githubusercontent.com/hcmlab/nova/master/packages/python-fixes/termcolor.py";
Client = new WebClient();
Client.DownloadFile(url, Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + "python\\") + "termcolor.py");

System.IO.Compression.ZipFile.ExtractToDirectory("python/tkinterfix.zip", "python/");
File.Delete("python/tkinterfix.zip");

try
{
//Temporary FIX for VGG FACE latest Keras version bug
string url = "https://raw.githubusercontent.com/hcmlab/nova/master/packages/python-fixes/vggface-fix.py";
Client = new WebClient();
Client.DownloadFile(url, sitepackagepath + "\\keras_vggface\\models.py");
}

catch { }

//DOWNLOAD required python scripts from git.

Directory.CreateDirectory("PythonScripts");
url = "https://raw.githubusercontent.com/hcmlab/nova/master/PythonScripts/ImageExplainerLime.py";
Client.DownloadFile(url, "PythonScripts\\ImageExplainerLime.py");
try
{
Directory.CreateDirectory("PythonScripts");
string url = "https://raw.githubusercontent.com/hcmlab/nova/master/PythonScripts/ImageExplainerLime.py";
Client.DownloadFile(url, "PythonScripts\\ImageExplainerLime.py");
}
catch
{
}

//File.Delete("requirements.txt");

//Environment.SetEnvironmentVariable("PYTHONPATH", current, EnvironmentVariableTarget.User);
}


}


}



}
Oops, something went wrong.

0 comments on commit 2d70bb5

Please sign in to comment.
You can’t perform that action at this time.