Skip to content

Commit

Permalink
Merge pull request #253 from hcmlab/develop
Browse files Browse the repository at this point in the history
support for tensorflow, merge features, local schemes
  • Loading branch information
tobiasbaur authored Jul 13, 2017
2 parents df05c98 + 6aabba3 commit ce3cb1f
Show file tree
Hide file tree
Showing 26 changed files with 862 additions and 403 deletions.
53 changes: 30 additions & 23 deletions Controls/Annotation/AnnoTierNewSchemeWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,23 @@
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>

<StackPanel Grid.Row="0" Margin="10">
<Separator Height="5" Visibility="Hidden"></Separator>
<TextBlock TextAlignment="Left" TextWrapping="Wrap" HorizontalAlignment="Stretch" FontSize="10" Width="120">
Discrete scheme with predefined labels
</TextBlock>
<Separator Height="15" Visibility="Hidden"></Separator>
<Button Name="button_discrete" Height="25" Width="120" Content="Discrete" Click="Button_Click"></Button>
<StackPanel Grid.Row="0" Margin="5" VerticalAlignment="Center">
<Button Name="button_discrete" Height="25" Width="100" Content="Discrete" Click="Button_Click"></Button>
</StackPanel>

<StackPanel Grid.Row="1" Margin="10">
<Separator Height="5" Visibility="Hidden"></Separator>
<TextBlock TextAlignment="Left" TextWrapping="Wrap" HorizontalAlignment="Stretch" FontSize="10" Width="120"><Run Text="Discrete scheme with "/><Run Text=" custom "/><Run Text="labels"/></TextBlock>
<Separator Height="15" Visibility="Hidden"></Separator>
<Button Name="button_free" Height="25" Width="120" Content="Free" Click="Button_Click"></Button>
<StackPanel Grid.Row="1" Margin="5" VerticalAlignment="Center">
<Button Name="button_free" Height="25" Width="100" Content="Free" Click="Button_Click"></Button>
</StackPanel>


<StackPanel Grid.Row="2" Margin="10">
<Separator Height="5" Visibility="Hidden"></Separator>
<TextBlock TextAlignment="Left" TextWrapping="Wrap" HorizontalAlignment="Stretch" FontSize="10" Width="120">
Scheme with continuous values
</TextBlock>
<Separator Height="15" Visibility="Hidden"></Separator>
<Button Name="button_continuous" Height="25" Width="120" Content="Continuous" Click="Button_Click"></Button>
<StackPanel Grid.Row="2" Margin="5" VerticalAlignment="Center">
<Button Name="button_continuous" Height="25" Width="100" Content="Continuous" Click="Button_Click"></Button>
</StackPanel>

<StackPanel Grid.Row="3" VerticalAlignment="Center" Visibility="Collapsed">
Expand All @@ -54,9 +41,20 @@
</TextBlock>
</StackPanel>

<Image Grid.Row="0" Grid.Column="1" Margin="10" Width="300" Source="/Resources/discrete.png"/>
<Image Grid.Row="1" Grid.Column="1" Margin="10" Width="300" Source="/Resources/free.png"/>
<Image Grid.Row="2" Grid.Column="1" Margin="10" Width="300" Source="/Resources/continuous.png"/>
<StackPanel Grid.Row="0" Grid.Column="1" Margin="5" >
<TextBlock TextAlignment="Left" TextWrapping="Wrap" HorizontalAlignment="Center">Scheme with predefined labels</TextBlock>
<Image Width="300" Source="/Resources/discrete.png"/>
</StackPanel>

<StackPanel Grid.Row="1" Grid.Column="1" Margin="5">
<TextBlock TextAlignment="Left" TextWrapping="Wrap" HorizontalAlignment="Center" Margin="78,0,80,0">Scheme with custom labels</TextBlock>
<Image Width="300" Source="/Resources/free.png"/>
</StackPanel>

<StackPanel Grid.Row="2" Grid.Column="1" Margin="5" >
<TextBlock TextAlignment="Left" TextWrapping="Wrap" HorizontalAlignment="Center">Scheme with continuous values</TextBlock>
<Image Width="300" Source="/Resources/continuous.png"/>
</StackPanel>

<Grid Grid.Row="3" Grid.Column="1" Margin="5" Visibility="Collapsed">
<Grid.RowDefinitions>
Expand Down Expand Up @@ -90,5 +88,14 @@
</Button>
</Grid>

<StackPanel Grid.Row="5" Margin="5" VerticalAlignment="Center">
<Button Name="button_cml" Height="25" Width="100" Content="Import" Click="Button_Click"></Button>
</StackPanel>

<StackPanel Grid.Row="5" Grid.Column="1" Margin="5,10,5,5" >
<TextBlock Name="textblock_cml" TextAlignment="Left" TextWrapping="Wrap" HorizontalAlignment="Center">Select a pre-defined scheme</TextBlock>
<ComboBox Name="combobox_cml" Width="240"></ComboBox>
</StackPanel>

</Grid>
</Window>
126 changes: 97 additions & 29 deletions Controls/Annotation/AnnoTierNewSchemeWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -19,47 +20,114 @@ namespace ssi
/// </summary>
public partial class AnnoTierNewSchemeWindow : Window
{
AnnoScheme.TYPE annotype = AnnoScheme.TYPE.FREE;
public AnnoTierNewSchemeWindow()
public class CMLScheme
{
public string Path { get; set; }
public string Name { get; set; }
public AnnoScheme.TYPE Type { get; set; }
public override string ToString()
{
return Name + " (" + Type.ToString() + ")";
}
}

public AnnoScheme Scheme { get; set; }

public bool LoadedFromFile { get; set; }

public AnnoTierNewSchemeWindow(double defaultSr)
{
InitializeComponent();

Scheme = new AnnoScheme() { SampleRate = defaultSr };
LoadedFromFile = false;

string schemesDir = Properties.Settings.Default.CMLDirectory + "\\" +
Defaults.CML.SchemeFolderName + "\\";

if (Directory.Exists(schemesDir))
{
foreach (string schemeDir in Directory.GetDirectories(schemesDir))
{
foreach (string schemeFile in Directory.GetFiles(schemeDir, "*.annotation"))
{
AnnoScheme.TYPE type = (AnnoScheme.TYPE)Enum.Parse(typeof(AnnoScheme.TYPE), System.IO.Path.GetFileName(schemeDir).ToUpper());
CMLScheme cmlScheme = new CMLScheme() { Path = schemeFile, Name = System.IO.Path.GetFileNameWithoutExtension(schemeFile), Type = type };
combobox_cml.Items.Add(cmlScheme);
}
}
}

if (combobox_cml.Items.Count > 0)
{
combobox_cml.SelectedIndex = 0;
}
else
{
combobox_cml.Visibility = Visibility.Collapsed;
button_cml.Visibility = Visibility.Collapsed;
textblock_cml.Visibility = Visibility.Collapsed;
}
}

private void Button_Click(object sender, RoutedEventArgs e)
{
DialogResult = true;
Button b = sender as Button;
switch (b.Name.ToString())

string name = (sender as Button).Name.ToString();

if (name == "button_cml")
{
case "button_discrete":
annotype = AnnoScheme.TYPE.DISCRETE;
break;
case "button_free":
annotype = AnnoScheme.TYPE.FREE;
break;
case "button_continuous":
annotype = AnnoScheme.TYPE.CONTINUOUS;
break;
case "button_point":
annotype = AnnoScheme.TYPE.POINT;
break;
case "button_polygon":
annotype = AnnoScheme.TYPE.POLYGON;
break;
case "button_graph":
annotype = AnnoScheme.TYPE.GRAPH;
break;
case "button_segmentation":
annotype = AnnoScheme.TYPE.SEGMENTATION;
break;
CMLScheme cmlScheme = (CMLScheme)combobox_cml.SelectedItem;
Scheme = AnnoList.LoadfromFile(cmlScheme.Path).Scheme;
LoadedFromFile = true;
}
else
{
AnnoScheme.TYPE annoType = AnnoScheme.TYPE.FREE;

}
switch (name)
{
case "button_discrete":
annoType = AnnoScheme.TYPE.DISCRETE;
break;
case "button_free":
annoType = AnnoScheme.TYPE.FREE;
break;
case "button_continuous":
annoType = AnnoScheme.TYPE.CONTINUOUS;
break;
case "button_point":
annoType = AnnoScheme.TYPE.POINT;
break;
case "button_polygon":
annoType = AnnoScheme.TYPE.POLYGON;
break;
case "button_graph":
annoType = AnnoScheme.TYPE.GRAPH;
break;
case "button_segmentation":
annoType = AnnoScheme.TYPE.SEGMENTATION;
break;
}

public AnnoScheme.TYPE Result()
{
return annotype;
Scheme.Type = annoType;

if (Scheme.Type == AnnoScheme.TYPE.CONTINUOUS)
{
Scheme.MinScore = 0.0;
Scheme.MaxScore = 1.0;
Scheme.MinOrBackColor = Defaults.Colors.GradientMin;
Scheme.MaxOrForeColor = Defaults.Colors.GradientMax;
}
else if (Scheme.Type == AnnoScheme.TYPE.POINT)
{
Scheme.NumberOfPoints = 1;
Scheme.MaxOrForeColor = Colors.Green;
}
}
}


}
}
3 changes: 2 additions & 1 deletion Controls/MainControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@
</MenuItem>
</MenuItem>
<MenuItem Header="LEARNING" Name="databaseCMLMenu">
<MenuItem Header="Merge Annotations" Name="databaseCMLMergeMenu" />
<MenuItem Header="Merge Annotations" Name="databaseCMLMergeAnnotationsMenu" />
<MenuItem Header="Extract Features" Name="databaseCMLExtractFeaturesMenu"/>
<MenuItem Header="Merge Features" Name="databaseCMLMergeFeaturesMenu"/>
<MenuItem Header="Train Models" Name="databaseCMLTrainMenu"/>
<MenuItem Header="Predict Annotations" Name="databaseCMLPredictMenu"/>
<MenuItem Header="Complete Current Annotation" Name="databaseCMLCompleteStepMenu"/>
Expand Down
85 changes: 8 additions & 77 deletions Controls/MainHandler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using Octokit;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
Expand Down Expand Up @@ -183,13 +185,14 @@ public MainHandler(MainControl view)
control.databaseLoadSessionMenu.Click += databaseLoadSession_Click;
control.databaseCMLCompleteStepMenu.Click += databaseCMLCompleteStep_Click;
control.databaseCMLExtractFeaturesMenu.Click += databaseCMLExtractFeatures_Click;
control.databaseCMLMergeFeaturesMenu.Click += databaseCMLMergeFeatures_Click;
control.databaseCMLTrainMenu.Click += databaseCMLTrain_Click;
control.databaseCMLPredictMenu.Click += databaseCMLPredict_Click;
control.databaseManageUsersMenu.Click += databaseManageUsers_Click;
control.databaseManageDBsMenu.Click += databaseManageDBs_Click;
control.databaseManageSessionsMenu.Click += databaseManageSessions_Click;
control.databaseManageAnnotationsMenu.Click += databaseManageAnnotations_Click;
control.databaseCMLMergeMenu.Click += databaseCMLMerge_Click;
control.databaseCMLMergeAnnotationsMenu.Click += databaseCMLMergeAnnotations_Click;

control.showSettingsMenu.Click += showSettings_Click;

Expand Down Expand Up @@ -269,6 +272,7 @@ public MainHandler(MainControl view)
Properties.Settings.Default.LastUpdateCheckDate = DateTime.Today.Date;
Properties.Settings.Default.Save();
checkForUpdates(true);
checkForCMLUpdates(true);
}


Expand All @@ -289,7 +293,7 @@ public MainHandler(MainControl view)
if (!(File.Exists(cmltrainexePath)))
{

updateCML();
checkForCMLUpdates();

}

Expand Down Expand Up @@ -321,80 +325,7 @@ public MainHandler(MainControl view)
/// <summary>
///
/// </summary>
private void updateCML()
{

/*
* CMLTrain and XMLchain executables are downloaded from the official SSI git repository.
* */

string SSIbinaryGitPath = "https://github.com/hcmlab/ssi/raw/master/bin/x64/vc140/";

//Download CMLtrain, if not present yet.
string cmltrainexe = "cmltrain.exe";
string cmltrainexePath = AppDomain.CurrentDomain.BaseDirectory + cmltrainexe;

try
{
DownloadFile(SSIbinaryGitPath + cmltrainexe, cmltrainexePath);
}
catch {
MessageBox.Show("Can't update tools, check your internet conenction!");
return;
}


//Download xmlchain, if not present yet.
string xmlchainexe = "xmlchain.exe";
string xmlchainexePath = AppDomain.CurrentDomain.BaseDirectory + xmlchainexe;

DownloadFile(SSIbinaryGitPath + xmlchainexe, xmlchainexePath);

//Download libmongoc-1.0.dll, if not present yet.
string libmongocdll = "libmongoc-1.0.dll";
string libmongocdllPath = AppDomain.CurrentDomain.BaseDirectory + libmongocdll;

DownloadFile(SSIbinaryGitPath + libmongocdll, libmongocdllPath);


//Download libbson-1.0.dll, if not present yet.
string libsondll = "libbson-1.0.dll";
string libbsondllPath = AppDomain.CurrentDomain.BaseDirectory + libsondll;

DownloadFile(SSIbinaryGitPath + libsondll, libbsondllPath);

//Download ssiframe.dll, if not present yet.
string ssiframedll = "ssiframe.dll";
string ssiframedllPath = AppDomain.CurrentDomain.BaseDirectory + ssiframedll;

DownloadFile(SSIbinaryGitPath + ssiframedll, ssiframedllPath);





if (File.Exists(xmlchainexePath) && File.Exists(cmltrainexePath) && File.Exists(libmongocdllPath) && File.Exists(libbsondllPath))
{

long sizexmlchain = new System.IO.FileInfo(xmlchainexePath).Length;
long sizecmltrain = new System.IO.FileInfo(cmltrainexePath).Length;
long sizelibmongocdll = new System.IO.FileInfo(libmongocdllPath).Length;
long sizelibsondll = new System.IO.FileInfo(libbsondllPath).Length;
long sizessiframedll = new System.IO.FileInfo(ssiframedllPath).Length;

if (sizexmlchain == 0 || sizecmltrain == 0 || sizelibmongocdll == 0 || sizelibsondll == 0)
{
if (File.Exists(xmlchainexePath)) File.Delete(xmlchainexePath);
if (File.Exists(cmltrainexePath)) File.Delete(cmltrainexePath);
if (File.Exists(libmongocdllPath)) File.Delete(libmongocdllPath);
if (File.Exists(libbsondllPath)) File.Delete(libbsondllPath);
if (File.Exists(ssiframedllPath)) File.Delete(ssiframedllPath);
MessageBox.Show("Could not update Cooperative Machine Learning Tools");
}
else MessageBox.Show("Successfully updated Cooperative Machine Learning Tools");
}

}




Expand Down
Loading

0 comments on commit ce3cb1f

Please sign in to comment.