Commit 5dd8aa60 authored by lafabregue's avatar lafabregue

proper implmentation of Model exportation

parent a4f994f2
......@@ -27,6 +27,9 @@ import jcl.learning.*;
import jcl.learning.methods.monostrategy.SingleClassification;
import jcl.learning.methods.monostrategy.ahc.LearningResultAHC;
import jcl.learning.methods.monostrategy.ahc.ParametersAHC;
import jcl.utils.exceptions.JCLFormatException;
import jcl.utils.exceptions.MethodNotImplementedException;
import jcl.utils.io.JCLModelExchange;
import jsl.Segmentation;
import jsl.regionalisation.vectorisation.Filters;
import mustic.gui.*;
......@@ -1092,8 +1095,20 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
} else {
TiffUtils.writeRGBTiff(bi, outputPath);
}
Packager.zipFile(out, name + "/imageColor.tif", outputfile);
Packager.zipFile(out, name + "/"+outputPath, outputfile);
outputfile.delete();
/** Save the model file */
try {
String modelPath = "model.jclm";
File modelFile = new File(modelPath);
JCLModelExchange.modelToFile(modelPath, ""+classification.getType(), classification);
Packager.zipFile(out, name + "/"+modelPath, modelFile);
modelFile.delete();
} catch (MethodNotImplementedException | JCLFormatException e) {
e.printStackTrace();
}
out.closeEntry();
ObjectOutputStream oos;
/**
......
......@@ -20,6 +20,7 @@ import mustic.gui.DataDesktopFrame;
import mustic.gui.MainFrame;
import mustic.gui.dialog.classifier.AttributeSelectionDialog;
import mustic.gui.panels.classifier.ClassifierPanel;
import mustic.gui.panels.classifier.Messages;
import mustic.gui.panels.classifier.SelectionModel;
import mustic.models.gui.panels.AttributeSelectionPanel;
......@@ -38,24 +39,25 @@ public class ApproachSelectionPanel extends JPanel {
private static final String METHOD_LABEL = "- method";
private static final String METHOD_LABEL = Messages.getString("ApproachSelectionPanel.1"); //$NON-NLS-1$
public static final int SINGLE_STRATEGY = 0;
private static final String MONO_STRATEGY_ALABEL = " Single strategy ";
private static final String MONO_STRATEGY_ALABEL = Messages.getString("ApproachSelectionPanel.2"); //$NON-NLS-1$
public static final int MULTI_STRATEGY = 1;
private static final String MULTI_STRATEGY_ALABEL = " Multi strategy (Samarah method) ";
private static final String MULTI_STRATEGY_ALABEL = Messages.getString("ApproachSelectionPanel.3"); //$NON-NLS-1$
public static final int MULTI_STRATEGY_ETC = 2;
private static final String MULTI_STRATEGY_ETC_ALABEL = " Multi strategy & multi source (work in progress) ";
private static final String MULTI_STRATEGY_ETC_ALABEL = Messages.getString("ApproachSelectionPanel.4"); //$NON-NLS-1$
public static final int MACLAW = 3;
private static final String MACLAW_ALABEL = " Attribute weighting (MACLAW method) ";
private static final String MACLAW_ALABEL = Messages.getString("ApproachSelectionPanel.5"); //$NON-NLS-1$
public static final int VOTING = 4;
private static final String VOTING_ALABEL = " Voting approach ";
private static final String VOTING_ALABEL = Messages.getString("ApproachSelectionPanel.6"); //$NON-NLS-1$
public static final int IMPORT_STRATEGY = 5;
private static final String IMPORT_STRATEGY_ALABEL = " Import from file";
private static final String IMPORT_STRATEGY_ALABEL = Messages.getString("ApproachSelectionPanel.7"); //$NON-NLS-1$
/*
* groupe de boutons type radiobox pour sélectionner le mode de
......@@ -69,6 +71,7 @@ public class ApproachSelectionPanel extends JPanel {
private SelectionModel modele;
//TODO remove data combo boxes, it should always be launched on the currently selected data
private JComboBox<String> dataComboBox = null;
private JComboBox<String> importDataComboBox = null;
......@@ -154,8 +157,8 @@ public class ApproachSelectionPanel extends JPanel {
currentPanel.add(new JLabel(METHOD_LABEL));
currentPanel.add(methodComboBox);
//currentPanel.add(new JLabel(DATA_LABEL));
currentPanel.add(new JLabel(" - "));
currentPanel.add(dataComboBox);
// currentPanel.add(new JLabel(" - "));
// currentPanel.add(dataComboBox);
break;
}
case 5: {
......@@ -165,7 +168,7 @@ public class ApproachSelectionPanel extends JPanel {
this.fatherContenair.votingDataComboBox.setEnabled(false);
currentPanel.add(fatherContenair.votingDataComboBox);
// currentPanel.add(fatherContenair.votingDataComboBox);
break;
}
// Multires TEST 25mai commentaire le code pour CLASSIFICATION MULTI-RESOLUTION
......@@ -217,8 +220,8 @@ public class ApproachSelectionPanel extends JPanel {
currentPanel.add(button);
currentPanel.add(new JLabel(METHOD_LABEL));
currentPanel.add(importMethodComboBox);
currentPanel.add(new JLabel(" - "));
currentPanel.add(importDataComboBox);
// currentPanel.add(new JLabel(" - "));
// currentPanel.add(importDataComboBox);
break;
}
......@@ -281,10 +284,10 @@ public class ApproachSelectionPanel extends JPanel {
JTaskPaneGroup attributsGroup = new JTaskPaneGroup();
attributsGroup.setTitle("Attributes selection and weigths configuration");
JPanel panelAttributs = new JPanel(new FlowLayout());
JPanel panelVisu = new JPanel(new FlowLayout());
panelVisu.add(fatherContenair.getButtonVisu());
panelVisu.add(fatherContenair.getLabelAide());
attributsGroup.add(panelVisu);
// JPanel panelVisu = new JPanel(new FlowLayout());
// panelVisu.add(fatherContenair.getButtonVisu());
// panelVisu.add(fatherContenair.getLabelAide());
// attributsGroup.add(panelVisu);
panelAttributs
.add(fatherContenair.attributeSelectionPanel);
attributsGroup.add(panelAttributs);
......@@ -348,10 +351,10 @@ public class ApproachSelectionPanel extends JPanel {
JTaskPaneGroup attributsGroup = new JTaskPaneGroup();
attributsGroup.setTitle("Attributes selection and weigths configuration");
JPanel panelAttributs = new JPanel(new FlowLayout());
JPanel panelVisu = new JPanel(new FlowLayout());
panelVisu.add(fatherContenair.getButtonVisu());
panelVisu.add(fatherContenair.getLabelAide());
attributsGroup.add(panelVisu);
// JPanel panelVisu = new JPanel(new FlowLayout());
// panelVisu.add(fatherContenair.getButtonVisu());
// panelVisu.add(fatherContenair.getLabelAide());
// attributsGroup.add(panelVisu);
panelAttributs
.add(fatherContenair.attributeSelectionPanel);
attributsGroup.add(panelAttributs);
......@@ -498,16 +501,14 @@ public class ApproachSelectionPanel extends JPanel {
/*
* construction de la liste contenante, c.a.d le résultat
*/
ButtonGroup res = new ButtonGroup();
res.add(singleStrategyButton);
res.add(multiStrategyButton);
res.add(multiStrategyEtcButton);
res.add(maclawStrategyButton);
res.add(votingStrategyButton);
res.add(importStrategyButton);
this.clusteringModeSelector = res;
clusteringModeSelector = new ButtonGroup();
clusteringModeSelector.add(singleStrategyButton);
clusteringModeSelector.add(multiStrategyButton);
clusteringModeSelector.add(multiStrategyEtcButton);
clusteringModeSelector.add(maclawStrategyButton);
clusteringModeSelector.add(votingStrategyButton);
clusteringModeSelector.add(importStrategyButton);
}
......
ApproachSelectionPanel.1=- method
ApproachSelectionPanel.2= Single strategy
ApproachSelectionPanel.3= Multi strategy (Samarah method)
ApproachSelectionPanel.4= Multi strategy & multi source (work in progress)
ApproachSelectionPanel.5= Attribute weighting (MACLAW method)
ApproachSelectionPanel.6= Voting approach
ApproachSelectionPanel.7= Import from file
ClassifierHandler.0=parametres ouverts
ClassifierHandler.1=parameters
ClassifierHandler.121=Balise
......@@ -23,7 +30,7 @@ ClassifierPanel.105=error\! class:ClassifierPanel, method:getParameters
ClassifierPanel.106=INFO: AHC Selected
ClassifierPanel.107=ERROR: Vous avez selectionne une methode qui n'est pas dans jComboBoxMethods
ClassifierPanel.108=error\! class:ClassifierPanel, method:getParameters
ClassifierPanel.1041=You must select an ARFF file.
ClassifierPanel.1041=You must select a jcl model file (.jclm).
ClassifierPanel.1042=Warning
ClassifierPanel.11=Classifier parameters
ClassifierPanel.110=Select a data
......@@ -91,6 +98,7 @@ ClassifierPanel.48=Error
ClassifierPanel.49=Select a data
ClassifierPanel.5=Parameters
ClassifierPanel.50=Error
ClassifierPanel.501=An error occurred while loading the model file :
ClassifierPanel.51=K-means
ClassifierPanel.52=tout est ok pr classif multi-d
ClassifierPanel.53=Select agents
......
ApproachSelectionPanel.1=- methode
ApproachSelectionPanel.2= Stratgie unique
ApproachSelectionPanel.3= Multi stratgie (mthode SAMARAH)
ApproachSelectionPanel.4= Multi stratgie & multi source (en cours)
ApproachSelectionPanel.5= Par poids des attributs (mthode MACLAW)
ApproachSelectionPanel.6= Approche par vote
ApproachSelectionPanel.7= Import de fichier
ClassifierHandler.0=parametres ouverts
ClassifierHandler.1=parameters
ClassifierHandler.121=Balise
ClassifierHandler.122=\ inconnue.
ClassifierHandler.2=\ not found
ClassifierHandler.3=Warning
ClassifierHandler.3=Attention
ClassifierHandler.4=\ not found
ClassifierHandler.5=Warning
ClassifierHandler.5=Attention
ClassifierHandler.6=\ not found
ClassifierHandler.65=Warning
ClassifierHandler.65=Attention
ClassifierHandler.85=Balise
ClassifierHandler.86=\ inconnue.
ClassifierHandler.87=Ouverture des parametres
ClassifierHandler.94=seed
ClassifierPanel.0=Select seeds
ClassifierPanel.1=Visualize bandes
ClassifierPanel.10=Method
ClassifierPanel.0=Selectionner les centres initiaux
ClassifierPanel.1=Visualisers les bandes
ClassifierPanel.10=Methode
ClassifierPanel.100=Learning agents ne doit pas etre vide
ClassifierPanel.101=sequence...
ClassifierPanel.102=other...
ClassifierPanel.102=autre...
ClassifierPanel.103=Erreur
ClassifierPanel.1041=Vous devez choisir un fichier ARFF.
ClassifierPanel.1042=Attention
......@@ -25,6 +32,8 @@ ClassifierPanel.105=error\! class:ClassifierPanel, method:getParameters
ClassifierPanel.106=INFO: AHC Selected
ClassifierPanel.107=ERROR: Vous avez selectionne une methode qui n'est pas dans jComboBoxMethods
ClassifierPanel.108=error\! class:ClassifierPanel, method:getParameters
ClassifierPanel.1041=Vous devez slectionner un fichier de model jcl (.jclm).
ClassifierPanel.1042=Attention
ClassifierPanel.11=Parametres de classification
ClassifierPanel.110=Selectionner une donne
ClassifierPanel.111=Erreur
......@@ -90,7 +99,8 @@ ClassifierPanel.47=Select a data
ClassifierPanel.48=Error
ClassifierPanel.49=Select a data
ClassifierPanel.5=Parameters
ClassifierPanel.50=Error
ClassifierPanel.50=Erreur
ClassifierPanel.501=Une erreur est survenue en chargant le fichier du model :
ClassifierPanel.51=K-means
ClassifierPanel.52=tout est ok pr classif multi-d
ClassifierPanel.53=Select agents
......
......@@ -36,7 +36,7 @@ public class ClusteringResultROI extends SimpleClusteringResult {
*/
public ClusteringResultROI(ROIImage image, ClassificationWeights weights,
int nbClusters, Data data, int[] clusterMap) {
super(null, clusterMap, null, weights, nbClusters, null, data, null);
super(null, clusterMap, null, weights, nbClusters, null, data, null, null);
this.image = image;
......
......@@ -46,11 +46,12 @@ public class GDALImageReaderWrapper extends ReaderWrapper {
public GDALImageReaderWrapper(String Path) throws Exception {
this.filePath = Path;
gdal.AllRegister();
dataSet = gdal.Open(Path, gdalconst.GA_ReadOnly);
dataSet = gdal.Open(this.filePath, gdalconst.GA_ReadOnly);
if (dataSet == null) {
throw new Exception("GDAL : Error when opening the file");
} else {
this.tile = null;
this.tileLoaded = false;
this.imageWidth = dataSet.GetRasterXSize();
this.imageHeight = dataSet.GetRasterYSize();
this.channelCount = dataSet.GetRasterCount();
......@@ -75,6 +76,7 @@ public class GDALImageReaderWrapper extends ReaderWrapper {
throw new Exception("GDAL : Error when opening the file");
} else {
this.tile = null;
this.tileLoaded = false;
this.imageWidth = dataSet.GetRasterXSize();
this.imageHeight = dataSet.GetRasterYSize();
this.channelCount = dataSet.GetRasterCount();
......@@ -169,6 +171,10 @@ public class GDALImageReaderWrapper extends ReaderWrapper {
currentTileWidth = imageWidth - tileX;
}
// it means that the memory might have been flushed
if (tile == null) {
dataSet = gdal.Open(this.filePath, gdalconst.GA_ReadOnly);
}
tile = new double[channelCount][currentTileWidth*currentTileHeight];
for (int i = 0 ; i < channelCount ; i++) {
Band band = dataSet.GetRasterBand(i+1);
......@@ -221,6 +227,7 @@ public class GDALImageReaderWrapper extends ReaderWrapper {
@Override
public void flushMemory() throws MethodNotImplementedException {
tile = null;
tileLoaded = false;
dataSet.delete();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment