Commit 9e92a038 by Chris Coughlin

Updated to Myriad 2.0 Snapshot, misc. bugfixes

Conflicts:
	src/main/java/com/emphysic/myriadtrainer/ui/MainApp.java
1 parent 35bc2b92
......@@ -26,7 +26,7 @@ The [Myriad library](https://gitlab.com/ccoughlin/datareader) must be installed
[Desktop](https://gitlab.com/ccoughlin/MyriadDesktop) isn't required for Trainer. Models created with Trainer can be used in Desktop or in other Myriad-based applications.
## Licensing
Copyright 2016 Emphysic, LLC.
Copyright 2017 Emphysic, LLC.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......
......@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.emphysic</groupId>
<artifactId>MyriadTrainer</artifactId>
<version>1.0-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
......@@ -60,7 +60,7 @@
<dependency>
<groupId>com.emphysic.myriad</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
......@@ -95,22 +95,22 @@
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-core</artifactId>
<version>1.2.0</version>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-data</artifactId>
<version>1.2.0</version>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-plot</artifactId>
<version>1.2.0</version>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.10</version>
<version>1.16.16</version>
<scope>provided</scope>
</dependency>
</dependencies>
......
/*
* com.emphysic.myriadtrainer.controllers.MainAppController
*
* Copyright (c) 2016 Emphysic LLC.
* Copyright (c) 2017 Emphysic LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -47,6 +47,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import java.util.Set;
import java.util.logging.Level;
......@@ -88,6 +89,7 @@ public class MainAppController {
*/
public enum preprocOp {
NONE,
BUNDLED,
ABSOLUTE,
BINARIZE,
BOX_BLUR,
......@@ -108,6 +110,7 @@ public class MainAppController {
*/
private String[] preprocOpDescriptions = {
"No preprocessing performed",
"Using preprocessor bundled with serialized model (if any)",
"Absolute Value",
"Set all values to 0 or 1 based on a threshold",
"Box blur",
......@@ -128,6 +131,7 @@ public class MainAppController {
*/
private String[] preprocOpClasses = {
null,
null,
AbsoluteValueOperation.class.toString(),
BinarizeOperation.class.toString(),
BoxBlur.class.toString(),
......@@ -192,7 +196,7 @@ public class MainAppController {
*/
//TODO: refactor here and in Desktop into separate lib
public void setOperation(preprocOp type) {
currentOp = null;
//currentOp = null;
switch (type) {
case ABSOLUTE:
currentOp = new AbsoluteValueOperation();
......@@ -221,7 +225,7 @@ public class MainAppController {
JOptionPane.OK_OPTION);
try {
int radius = Integer.parseInt(r);
if (null != type) switch (type) {
switch (type) {
case GAUSSIAN_BLUR:
currentOp = new GaussianBlur(radius);
break;
......@@ -279,7 +283,7 @@ public class MainAppController {
r1 = Integer.parseInt(toks[0]);
r2 = Integer.parseInt(toks[1]);
currentOp = new DifferenceOfGaussiansOperation(r1, r2);
} catch (Exception e) {
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(frame,
"Please enter valid numbers for blur radius.",
"Invalid Radius Specified",
......@@ -320,8 +324,14 @@ public class MainAppController {
JOptionPane.ERROR_MESSAGE);
}
break;
case BUNDLED:
if (currentOp != null) {
preprocOpDescriptions[1] = "Bundled: " + currentOp.getClass().toString();
}
break;
case NONE:
default:
currentOp = null;
break;
}
}
......@@ -404,7 +414,7 @@ public class MainAppController {
if (loss == null || loss.isEmpty()) {
lossfunction = new HingeLoss();
} else {
switch (loss.toLowerCase()) {
switch (loss.toLowerCase(Locale.getDefault())) {
case "hinge":
lossfunction = new HingeLoss();
break;
......@@ -442,7 +452,7 @@ public class MainAppController {
if (reg == null) {
regFunction = new L1();
} else {
switch (reg.toLowerCase()) {
switch (reg.toLowerCase(Locale.getDefault())) {
case "l1":
regFunction = new L1();
break;
......@@ -720,7 +730,7 @@ public class MainAppController {
BIGFEATURES = t;
}
public class MyriadModel {
public static class MyriadModel {
private MLROIFinder model;
private double accuracy;
......
/*
* com.emphysic.myriadtrainer.ui.AboutDialog
*
* Copyright (c) 2016 Emphysic LLC.
* Copyright (c) 2017 Emphysic LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -119,7 +119,7 @@ public class AboutDialog extends javax.swing.JDialog {
File urlFile = new File(url.getPath());
copyright = new String(Files.readAllBytes(urlFile.toPath()));
} catch (IOException ioe) {
copyright = "Copyright (C) 2016 Emphysic LLC.";
copyright = "Copyright (C) 2017 Emphysic LLC.";
}
return copyright;
}
......
/*
* com.emphysic.myriadtrainer.ui.AboutEmphysicDialog
*
* Copyright (c) 2016 Emphysic LLC.
* Copyright (c) 2017 Emphysic LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
......@@ -89,6 +89,9 @@
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="folderTextField">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="folderTextFieldActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="chooseFldrBtn">
<Properties>
......
/*
* com.emphysic.myriadtrainer.ui.AddDataDialog
*
* Copyright (c) 2016 Emphysic LLC.
* Copyright (c) 2017 Emphysic LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -17,17 +17,19 @@
*/
package com.emphysic.myriadtrainer.ui;
import java.nio.file.Files;
import java.nio.file.Paths;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
/**
* Add folders to Myriad model training.
* Copyright (C) 2016 Emphysic LLC. All rights reserved.
* Copyright (C) 2017 Emphysic LLC. All rights reserved.
* @author ccoughlin
*/
public class AddDataDialog extends javax.swing.JDialog {
private DataFolder df;
private transient DataFolder df;
/**
* Creates new form AddDataDialog
......@@ -61,6 +63,12 @@ public class AddDataDialog extends javax.swing.JDialog {
jLabel1.setText("Data Folder:");
folderTextField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
folderTextFieldActionPerformed(evt);
}
});
chooseFldrBtn.setText("Choose...");
chooseFldrBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
......@@ -162,17 +170,35 @@ public class AddDataDialog extends javax.swing.JDialog {
}//GEN-LAST:event_chooseFldrBtnActionPerformed
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
Object source = evt.getSource();
if (source == btnOK) {
df = new DataFolder();
addDataFolder();
}//GEN-LAST:event_btnOKActionPerformed
private void folderTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_folderTextFieldActionPerformed
addDataFolder();
}//GEN-LAST:event_folderTextFieldActionPerformed
/**
* Adds a new data folder to the test/train set.
*/
private void addDataFolder() {
df = new DataFolder();
if (signalsRadioButton.isSelected()) {
df.type = DataFolder.datatype.SIGNAL;
df.type = DataFolder.DATATYPE.SIGNAL;
} else {
df.type = DataFolder.datatype.NOISE;
df.type = DataFolder.DATATYPE.NOISE;
}
String path = folderTextField.getText();
if (path != null && !path.isEmpty()) {
df.folderPath = folderTextField.getText();
if (Files.exists(Paths.get(path))) {
df.folderPath = folderTextField.getText();
} else {
JOptionPane.showMessageDialog(this.getParent(),
"Please ensure the path exists and you have access to its contents.",
"Unable To Access Folder",
JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.warningIcon"));
return;
}
} else {
JOptionPane.showMessageDialog(this.getParent(),
"Please enter a path to the samples.",
......@@ -181,16 +207,12 @@ public class AddDataDialog extends javax.swing.JDialog {
UIManager.getIcon("OptionPane.warningIcon"));
return;
}
}
else {
df = null;
}
setVisible(false);
}//GEN-LAST:event_btnOKActionPerformed
setVisible(false);
}
public static class DataFolder {
enum datatype {SIGNAL, NOISE};
datatype type;
enum DATATYPE {SIGNAL, NOISE};
DATATYPE type;
String folderPath;
}
......
/*
* com.emphysic.myriadtrainer.ui.DataPanel
*
* Copyright (c) 2016 Emphysic LLC.
* Copyright (c) 2017 Emphysic LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -18,8 +18,8 @@
package com.emphysic.myriadtrainer.ui;
import com.emphysic.myriadtrainer.ui.AddDataDialog.DataFolder;
import static com.emphysic.myriadtrainer.ui.AddDataDialog.DataFolder.datatype.NOISE;
import static com.emphysic.myriadtrainer.ui.AddDataDialog.DataFolder.datatype.SIGNAL;
import static com.emphysic.myriadtrainer.ui.AddDataDialog.DataFolder.DATATYPE.NOISE;
import static com.emphysic.myriadtrainer.ui.AddDataDialog.DataFolder.DATATYPE.SIGNAL;
import java.io.File;
import java.util.List;
import java.util.ArrayList;
......@@ -142,14 +142,14 @@ public class DataPanel extends javax.swing.JPanel {
public void addPositiveSamplesFolder(File folder) {
DefaultTreeModel model = (DefaultTreeModel)DataTree.getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode)model.getRoot();
//DefaultMutableTreeNode root = (DefaultMutableTreeNode)model.getRoot();
DefaultMutableTreeNode pos = getPositiveSamplesTreeNode();
pos.add(new DefaultMutableTreeNode(folder.getAbsolutePath()));
}
public void addNegativeSamplesFolder(File folder) {
DefaultTreeModel model = (DefaultTreeModel)DataTree.getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode)model.getRoot();
//DefaultMutableTreeNode root = (DefaultMutableTreeNode)model.getRoot();
DefaultMutableTreeNode neg = getNegativeSamplesTreeNode();
neg.add(new DefaultMutableTreeNode(folder.getAbsolutePath()));
}
......
/*
* com.emphysic.myriadtrainer.ui.LicenseDialog
*
* Copyright (c) 2016 Emphysic LLC.
* Copyright (c) 2017 Emphysic LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -34,15 +34,17 @@ public class LicenseDialog extends javax.swing.JDialog {
public LicenseDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
String license;
String license = "Licensed under the Apache License.\nPlease refer to the LICENSE file for additional details.";
try {
InputStream is = AboutDialog.class.getResourceAsStream("/LICENSE");
byte[] b = new byte[is.available()];
is.read(b);
license = new String(b);
int bytesRead = is.read(b);
if (bytesRead > 0) {
license = new String(b);
}
is.close();
} catch (IOException ioe) {
log.warn("Unable to read license file, error was: " + ioe.getMessage());
license = "Licensed under the Apache License.\nPlease refer to the LICENSE file for additional details.";
}
licenseTextArea.setText(license);
licenseTextArea.setCaretPosition(0);
......
......@@ -50,7 +50,7 @@
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+X"/>
</Property>
<Property name="text" type="java.lang.String" value="Exit Model Trainer"/>
<Property name="text" type="java.lang.String" value="Exit Trainer"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exitAppMenuItemActionPerformed"/>
......@@ -123,7 +123,7 @@
</NonVisualComponents>
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
<Property name="title" type="java.lang.String" value="Myriad Model Trainer"/>
<Property name="title" type="java.lang.String" value="Myriad Trainer"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/>
......@@ -224,14 +224,14 @@
</Group>
<EmptySpace min="-2" pref="31" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jSlider1" pref="232" max="32767" attributes="0"/>
<Component id="jSlider2" pref="232" max="32767" attributes="0"/>
<Component id="jSlider1" max="32767" attributes="0"/>
<Component id="jSlider2" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel7" min="-2" pref="122" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="preprocComboBox" pref="161" max="32767" attributes="0"/>
<Component id="preprocComboBox" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
......@@ -571,7 +571,7 @@
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="asgdRegFunctionLabel" pref="287" max="32767" attributes="0"/>
<Component id="asgdRegFunctionLabel" max="32767" attributes="0"/>
<Component id="jLabel15" max="32767" attributes="0"/>
</Group>
<EmptySpace pref="132" max="32767" attributes="0"/>
......@@ -995,6 +995,9 @@
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="100"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="testPointsTextFieldActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="runTestButton">
<Properties>
......
Copyright 2016 Emphysic LLC.
Copyright 2017 Emphysic LLC.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!