diff --git a/src/dataPlotsFX/TDControlFX.java b/src/dataPlotsFX/TDControlFX.java index 3f162249..1c46fc4b 100644 --- a/src/dataPlotsFX/TDControlFX.java +++ b/src/dataPlotsFX/TDControlFX.java @@ -114,7 +114,9 @@ public class TDControlFX extends TDControl implements UserDisplayNodeFX { ArrayList dataBlocks=new ArrayList(); PamDataBlock dataBlock=this.tdDisplayController.getUserDisplayProcess().getParentDataBlock(); if (TDDataProviderRegisterFX.getInstance().findDataProvider(dataBlock)!=null) dataBlocks.add(dataBlock); - if (dataBlock!=null) System.out.println("TDControldFX: parent datablock "+dataBlock.getDataName()); + if (dataBlock!=null) { + System.out.println("TDControldFX: parent datablock "+dataBlock.getDataName()); + } else{ System.out.println("TDControldFX: parent datablock null"); return dataBlocks; diff --git a/src/pamViewFX/PamGuiTabFX.java b/src/pamViewFX/PamGuiTabFX.java index c458f21e..9e1f3fb2 100644 --- a/src/pamViewFX/PamGuiTabFX.java +++ b/src/pamViewFX/PamGuiTabFX.java @@ -201,7 +201,7 @@ public class PamGuiTabFX extends PamTabFX { * @return the internal pane which has been added */ public PamGuiInternalPane addInternalPane(UserDisplayNodeFX userDisplayNodeFX){ - System.out.println("UserDisplayNodeFX: " + userDisplayNodeFX); +// System.out.println("UserDisplayNodeFX: " + userDisplayNodeFX); if (userDisplayNodeFX==null || userDisplayNodeFX.getNode()==null) return null; for (PamGuiInternalPane internalPane: this.internalPanes) { diff --git a/src/rawDeepLearningClassifier/dlClassification/DLDataUnit.java b/src/rawDeepLearningClassifier/dlClassification/DLDataUnit.java index 869f9894..4fa03e38 100644 --- a/src/rawDeepLearningClassifier/dlClassification/DLDataUnit.java +++ b/src/rawDeepLearningClassifier/dlClassification/DLDataUnit.java @@ -2,7 +2,7 @@ package rawDeepLearningClassifier.dlClassification; import PamguardMVC.DataUnitBaseData; import PamguardMVC.PamDataUnit; -import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction; +import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; /** * A data unit created from classification results of DL model. this data unit holds one model results, i.e. @@ -37,7 +37,7 @@ public class DLDataUnit extends PamDataUnit { public DLDataUnit(DataUnitBaseData baseData, float[] data) { super(baseData); //System.out.println("DLDataUnit: " + this.getChannelBitmap()); - this.modelResult = new GenericPrediction(data); + this.modelResult = new StandardPrediction(data); } public DLDataUnit(DataUnitBaseData baseData, PredictionResult modelResult) { diff --git a/src/rawDeepLearningClassifier/dlClassification/DLTaskThread.java b/src/rawDeepLearningClassifier/dlClassification/DLTaskThread.java index 51d6c6e7..c1d77c41 100644 --- a/src/rawDeepLearningClassifier/dlClassification/DLTaskThread.java +++ b/src/rawDeepLearningClassifier/dlClassification/DLTaskThread.java @@ -7,7 +7,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import PamguardMVC.PamDataUnit; import rawDeepLearningClassifier.dlClassification.genericModel.DLModelWorker; -import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction; +import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; import rawDeepLearningClassifier.segmenter.GroupedRawData; /** @@ -52,7 +52,7 @@ public abstract class DLTaskThread extends Thread { System.out.println("DL TASK THREAD: " + "The queue size is " + queue.size()); ArrayList groupedRawData = queue.remove(0); - ArrayList modelResult = dlModelWorker.runModel(groupedRawData, + ArrayList modelResult = dlModelWorker.runModel(groupedRawData, groupedRawData.get(0).getParentDataBlock().getSampleRate(), 0); //TODO channel? for (int i =0; i modelResult = (ArrayList) getDLWorker().runModel(groupedRawData, + ArrayList modelResult = (ArrayList) getDLWorker().runModel(groupedRawData, groupedRawData.get(0).getParentDataBlock().getSampleRate(), 0); if (modelResult==null) { @@ -205,14 +205,58 @@ public abstract class StandardClassifierModel implements DLClassiferModel, PamSe } @Override - public void newDLResult(GenericPrediction soundSpotResult, PamDataUnit groupedRawData) { - soundSpotResult.setClassNameID(GenericDLClassifier.getClassNameIDs(getDLParams())); - soundSpotResult.setBinaryClassification(GenericDLClassifier.isBinaryResult(soundSpotResult, getDLParams())); + public void newDLResult(StandardPrediction soundSpotResult, PamDataUnit groupedRawData) { + soundSpotResult.setClassNameID(getClassNameIDs(getDLParams())); + soundSpotResult.setBinaryClassification(isDecision(soundSpotResult, getDLParams())); newResult(soundSpotResult, groupedRawData); } } + /** + * Make a decision on whether a result passed a decision + * @param modelResult - the model result. + * @param modelParmas - the model parameters. + * @return true if a threshold has been met. + */ + public boolean isDecision(StandardPrediction modelResult, StandardModelParams modelParmas) { + return isBinaryResult(modelResult, modelParmas); + } + + + + /** + * Get the class name IDs + * @return an array of class name IDs + */ + public static short[] getClassNameIDs(StandardModelParams standardModelParams) { + if (standardModelParams.classNames==null || standardModelParams.classNames.length<=0) return null; + short[] nameIDs = new short[standardModelParams.classNames.length]; + for (int i = 0 ; igenericModelParams.threshold && genericModelParams.binaryClassification[i]) { + // System.out.println("SoundSpotClassifier: prediciton: " + i + " passed threshold with val: " + modelResult.getPrediction()[i]); + return true; + } + } + return false; + } + @Override public void closeModel() { @@ -225,7 +269,7 @@ public abstract class StandardClassifierModel implements DLClassiferModel, PamSe * @param modelResult - the model result; * @param groupedRawData - the grouped raw data. */ - protected void newResult(GenericPrediction modelResult, PamDataUnit groupedRawData) { + protected void newResult(StandardPrediction modelResult, PamDataUnit groupedRawData) { if (groupedRawData instanceof GroupedRawData) { this.dlControl.getDLClassifyProcess().newModelResult(modelResult, (GroupedRawData) groupedRawData); } diff --git a/src/rawDeepLearningClassifier/dlClassification/animalSpot/SoundSpotClassifier.java b/src/rawDeepLearningClassifier/dlClassification/animalSpot/SoundSpotClassifier.java index 214149a3..d9374432 100644 --- a/src/rawDeepLearningClassifier/dlClassification/animalSpot/SoundSpotClassifier.java +++ b/src/rawDeepLearningClassifier/dlClassification/animalSpot/SoundSpotClassifier.java @@ -15,7 +15,7 @@ import rawDeepLearningClassifier.DLControl; import rawDeepLearningClassifier.dlClassification.DLClassiferModel; import rawDeepLearningClassifier.dlClassification.StandardClassifierModel; import rawDeepLearningClassifier.dlClassification.genericModel.DLModelWorker; -import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction; +import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; import rawDeepLearningClassifier.layoutFX.DLCLassiferModelUI; /** @@ -53,7 +53,7 @@ public class SoundSpotClassifier extends StandardClassifierModel { /** * The deep learning model worker. */ - private DLModelWorker soundSpotWorker; + private DLModelWorker soundSpotWorker; public SoundSpotClassifier(DLControl dlControl) { @@ -171,7 +171,7 @@ public class SoundSpotClassifier extends StandardClassifierModel { @Override - public DLModelWorker getDLWorker() { + public DLModelWorker getDLWorker() { if (soundSpotWorker==null) { soundSpotWorker = new SoundSpotWorker(); } diff --git a/src/rawDeepLearningClassifier/dlClassification/animalSpot/SoundSpotResult.java b/src/rawDeepLearningClassifier/dlClassification/animalSpot/SoundSpotResult.java index 88178ab1..e94a9c56 100644 --- a/src/rawDeepLearningClassifier/dlClassification/animalSpot/SoundSpotResult.java +++ b/src/rawDeepLearningClassifier/dlClassification/animalSpot/SoundSpotResult.java @@ -1,13 +1,13 @@ package rawDeepLearningClassifier.dlClassification.animalSpot; -import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction; +import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; /** * Result from the SoundSpotClassifier. * @author Jamie Macaulay * */ -public class SoundSpotResult extends GenericPrediction { +public class SoundSpotResult extends StandardPrediction { public SoundSpotResult(float[] prob, boolean isBinary) { super(prob, isBinary); diff --git a/src/rawDeepLearningClassifier/dlClassification/animalSpot/SoundSpotWorker.java b/src/rawDeepLearningClassifier/dlClassification/animalSpot/SoundSpotWorker.java index b7115630..735db07c 100644 --- a/src/rawDeepLearningClassifier/dlClassification/animalSpot/SoundSpotWorker.java +++ b/src/rawDeepLearningClassifier/dlClassification/animalSpot/SoundSpotWorker.java @@ -7,7 +7,7 @@ import org.jamdev.jdl4pam.animalSpot.AnimalSpotParams; import rawDeepLearningClassifier.DLControl; import rawDeepLearningClassifier.dlClassification.genericModel.DLModelWorker; -import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction; +import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; /** @@ -19,7 +19,7 @@ import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction * @author Jamie Macaulay * */ -public class SoundSpotWorker extends DLModelWorker { +public class SoundSpotWorker extends DLModelWorker { /** diff --git a/src/rawDeepLearningClassifier/dlClassification/archiveModel/ArchiveModelClassifier.java b/src/rawDeepLearningClassifier/dlClassification/archiveModel/ArchiveModelClassifier.java index cd58771f..5a7ff152 100644 --- a/src/rawDeepLearningClassifier/dlClassification/archiveModel/ArchiveModelClassifier.java +++ b/src/rawDeepLearningClassifier/dlClassification/archiveModel/ArchiveModelClassifier.java @@ -14,7 +14,7 @@ import rawDeepLearningClassifier.dlClassification.DLClassiferModel; import rawDeepLearningClassifier.dlClassification.StandardClassifierModel; import rawDeepLearningClassifier.dlClassification.animalSpot.StandardModelParams; import rawDeepLearningClassifier.dlClassification.genericModel.DLModelWorker; -import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction; +import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; import rawDeepLearningClassifier.dlClassification.ketos.KetosDLParams; import rawDeepLearningClassifier.dlClassification.ketos.KetosUI; import rawDeepLearningClassifier.layoutFX.DLCLassiferModelUI; @@ -81,7 +81,7 @@ public abstract class ArchiveModelClassifier extends StandardClassifierModel { @Override - public DLModelWorker getDLWorker() { + public DLModelWorker getDLWorker() { return getModelWorker(); } diff --git a/src/rawDeepLearningClassifier/dlClassification/archiveModel/ArchiveModelWorker.java b/src/rawDeepLearningClassifier/dlClassification/archiveModel/ArchiveModelWorker.java index ab78a47b..8cc339f5 100644 --- a/src/rawDeepLearningClassifier/dlClassification/archiveModel/ArchiveModelWorker.java +++ b/src/rawDeepLearningClassifier/dlClassification/archiveModel/ArchiveModelWorker.java @@ -26,7 +26,7 @@ import rawDeepLearningClassifier.DLControl; import rawDeepLearningClassifier.dlClassification.animalSpot.StandardModelParams; import rawDeepLearningClassifier.dlClassification.genericModel.DLModelWorker; import rawDeepLearningClassifier.dlClassification.genericModel.GenericModelWorker; -import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction; +import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; /** * @@ -228,8 +228,8 @@ public class ArchiveModelWorker extends GenericModelWorker { @Override - public GenericPrediction makeModelResult(float[] prob, double time) { - GenericPrediction prediction = new GenericPrediction(prob); + public StandardPrediction makeModelResult(float[] prob, double time) { + StandardPrediction prediction = new StandardPrediction(prob); prediction.setAnalysisTime(time); return prediction; } @@ -251,6 +251,10 @@ public class ArchiveModelWorker extends GenericModelWorker { public ArchiveModel getModel() { return dlModel; } + + protected void setModel(ArchiveModel dlModel) { + this.dlModel = dlModel; + } @Override public boolean isModelNull() { diff --git a/src/rawDeepLearningClassifier/dlClassification/delphinID/DelphinIDClassifier.java b/src/rawDeepLearningClassifier/dlClassification/delphinID/DelphinIDClassifier.java index 375efb79..b55c8655 100644 --- a/src/rawDeepLearningClassifier/dlClassification/delphinID/DelphinIDClassifier.java +++ b/src/rawDeepLearningClassifier/dlClassification/delphinID/DelphinIDClassifier.java @@ -13,7 +13,7 @@ import rawDeepLearningClassifier.dlClassification.DLClassiferModel; import rawDeepLearningClassifier.dlClassification.StandardClassifierModel; import rawDeepLearningClassifier.dlClassification.animalSpot.StandardModelParams; import rawDeepLearningClassifier.dlClassification.genericModel.DLModelWorker; -import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction; +import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; import rawDeepLearningClassifier.layoutFX.DLCLassiferModelUI; /** @@ -86,6 +86,15 @@ public class DelphinIDClassifier extends StandardClassifierModel { return delphinIDParams; } + + + @Override + public boolean isDecision(StandardPrediction modelResult, StandardModelParams modelParmas) { + //TODO + //DelphinID uses a different decision making process to most of the standard classifiers which just pass a binary threhsoild. + return false; + } + @Override @@ -111,7 +120,7 @@ public class DelphinIDClassifier extends StandardClassifierModel { @Override - public DLModelWorker getDLWorker() { + public DLModelWorker getDLWorker() { if (delphinIDWorker==null) { delphinIDWorker = new DelphinIDWorker(); } diff --git a/src/rawDeepLearningClassifier/dlClassification/delphinID/DelphinIDPrediction.java b/src/rawDeepLearningClassifier/dlClassification/delphinID/DelphinIDPrediction.java index b5140ee4..158f013a 100644 --- a/src/rawDeepLearningClassifier/dlClassification/delphinID/DelphinIDPrediction.java +++ b/src/rawDeepLearningClassifier/dlClassification/delphinID/DelphinIDPrediction.java @@ -1,8 +1,8 @@ package rawDeepLearningClassifier.dlClassification.delphinID; -import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction; +import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; -public class DelphinIDPrediction extends GenericPrediction{ +public class DelphinIDPrediction extends StandardPrediction{ public DelphinIDPrediction(float[] prob) { super(prob); diff --git a/src/rawDeepLearningClassifier/dlClassification/delphinID/DelphinIDTest.java b/src/rawDeepLearningClassifier/dlClassification/delphinID/DelphinIDTest.java new file mode 100644 index 00000000..ad358d4a --- /dev/null +++ b/src/rawDeepLearningClassifier/dlClassification/delphinID/DelphinIDTest.java @@ -0,0 +1,243 @@ +package rawDeepLearningClassifier.dlClassification.delphinID; + +import java.io.IOException; +import java.util.ArrayList; + +import PamUtils.PamArrayUtils; +import PamguardMVC.DataUnitBaseData; +import rawDeepLearningClassifier.dlClassification.animalSpot.StandardModelParams; +import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; +import rawDeepLearningClassifier.segmenter.SegmenterDetectionGroup; +import us.hebi.matlab.mat.format.Mat5; +import us.hebi.matlab.mat.format.Mat5File; +import us.hebi.matlab.mat.types.Matrix; +import us.hebi.matlab.mat.types.Struct; +import whistleClassifier.WhistleContour; +import whistlesAndMoans.AbstractWhistleDataUnit; + + +/** + * A delphinID test suite. + * + * @author Jamie Macaulay + * + */ +public class DelphinIDTest { + + public static DelphinIDWorker prepDelphinIDModel(String modelPath) { + + //create the delphinID worker. + DelphinIDWorker delphinIDWorker = new DelphinIDWorker(); + + StandardModelParams params = new StandardModelParams(); + params.modelPath = modelPath; + + //prepare the model + delphinIDWorker.prepModel(params, null); + + return delphinIDWorker; + } + + + /** + * Load whistle contours from a MAT file. () + * + * @param filePath - the file path. + * + * @return a list of whistle contour objects from the mat file. + */ + public static ArrayList getWhistleContoursMAT(String filePath){ + + ArrayList contours = new ArrayList(); + + // SegmenterDetectionGroup segmenterDetectionGroup = new SegmenterDetectionGroup(0, 0, 0, 0); + + // Read scalar from nested struct + try { + Mat5File matFile = Mat5.readFromFile(filePath); + Struct whistlesStruct = matFile.getStruct("whistles"); + + double fftLen = matFile.getMatrix("fftlen").getDouble(0); + double fftHop = matFile.getMatrix("ffthop").getDouble(0); + double sampleRate = matFile.getMatrix("samplerate").getDouble(0); + + for (int i=0; i< whistlesStruct.getNumElements(); i++) { + DataUnitBaseData basicData = new DataUnitBaseData(); + + long timeMillis = ((Matrix)whistlesStruct.get("millis", i)).getLong(0); + basicData.setTimeMilliseconds(timeMillis); + + long sampleDuration = ((Matrix)whistlesStruct.get("sampleDuration", i)).getLong(0); + basicData.setSampleDuration(sampleDuration); + + basicData.setMillisecondDuration(1000.*(sampleDuration/sampleRate)); + + int channelMap = ((Matrix)whistlesStruct.get("channelMap", i)).getInt(0); + basicData.setChannelBitmap(channelMap); + + long uid = ((Matrix)whistlesStruct.get("UID", i)).getLong(0); + basicData.setUID(uid); + + long startSample = ((Matrix)whistlesStruct.get("startSample", i)).getLong(0); + basicData.setStartSample(startSample); + + int nSlices = ((Matrix)whistlesStruct.get("nSlices", i)).getInt(0); + + double[] freq = new double[nSlices]; + double[] times = new double[nSlices]; + + Matrix contourStruct = whistlesStruct.getMatrix("contour", i); + for (int j=0; j segmentWhsitleData(ArrayList whistles, long dataStartMillis, + double segLen, double segHop){ + + ArrayList group = new ArrayList(); + + //find the maximum whistle time + long maxTime = Long.MIN_VALUE; + long endTime = 0; + for (AbstractWhistleDataUnit whislte: whistles) { + endTime = (long) (whislte.getTimeMilliseconds()+whislte.getDurationInMilliseconds()); + if (endTime>maxTime) maxTime=endTime; + } + + long segStart = dataStartMillis; + long segEnd = (long) (segStart+segLen); + + long whistleStart; + long whistleEnd; + SegmenterDetectionGroup whistleGroup; + while (segStart=segStart && whistleStart=segStart && whistleEnd whistleContours = getWhistleContoursMAT(whistleContourPath); + + + //segment the whistle detections + ArrayList segments = segmentWhsitleData(whistleContours, dataStartMillis, + segLen, segHop); + + for (int i=0; i aSegment = new ArrayList(); + aSegment.add(segments.get(i)); + + //the prediciton. + ArrayList predicition = model.runModel(aSegment, sampleRate, 1); + + float[] output = predicition.get(0).getPrediction(); + + } + + // for (int i=0; i dataUnits, float sampleRate, int iChan){ - + //Get a list of of the model transforms. ArrayList modelTransforms = getModelTransforms(); @SuppressWarnings("unchecked") - ArrayList whistleGroups = (ArrayList) dataUnits; - + ArrayList whistleGroups = (ArrayList) dataUnits; + //the number of chunks. int numChunks = whistleGroups.size(); //data input into the model - a stack of spectrogram images. float[][][] transformedDataStack = new float[numChunks][][]; -// -// //generate the spectrogram stack. -// AudioData soundData; -// double[][] transformedData2; //spec data -// double[] transformedData1; //waveform data -// for (int j=0; j points = whistContours2Points(whistleGroup); - Canvas canvas = makeScatterImage(points, size, new double[]{0, whistleGroup.getDurationInMilliseconds()}, freqLimits, 5.); - - WritableImage image = canvas.getGraphicsContext2D().getCanvas().snapshot(null, null); + //does not work becaue it has to be on the AWT thread. + BufferedImage canvas = makeScatterImage(points, size, new double[]{0, whistleGroup.getDurationInMilliseconds()}, freqLimits, 5.); double[][] imaged = new double[(int) size[0]][(int) size[1]]; - Color color; + int color; for (int i=0; i whistContours2Points(SegmenterDetectionGroup whistleGroup) { + + ArrayList contours = new ArrayList(); + + AbstractWhistleDataUnit whistleContour; + + long segStart = whistleGroup.getTimeMilliseconds(); + + for (int i=0; i points, double[] size, double[] xlims, double[] ylims, double markerSize) { +// +// Canvas canvas = new Canvas(size[0], size[1]); +// +// double x, y; +// for (int j=0; j points, double[] size, double[] xlims, double[] ylims, double markerSize) { - Canvas canvas = new Canvas(size[0], size[1]); + BufferedImage canvas = new BufferedImage((int) size[0], (int) size[1], BufferedImage.TYPE_INT_RGB); double x, y; - for (int i=0; igenericModelParams.threshold && genericModelParams.binaryClassification[i]) { - // System.out.println("SoundSpotClassifier: prediciton: " + i + " passed threshold with val: " + modelResult.getPrediction()[i]); - return true; - } - } - return false; - } - - // @Override // public ArrayList checkSettingsOK() { // return checkSettingsOK(genericModelParams, dlControl); @@ -234,7 +203,7 @@ public class GenericDLClassifier extends StandardClassifierModel { } @Override - public DLModelWorker getDLWorker() { + public DLModelWorker getDLWorker() { return this.genericModelWorker; } diff --git a/src/rawDeepLearningClassifier/dlClassification/genericModel/GenericModelWorker.java b/src/rawDeepLearningClassifier/dlClassification/genericModel/GenericModelWorker.java index fa7ecdd7..cb182031 100644 --- a/src/rawDeepLearningClassifier/dlClassification/genericModel/GenericModelWorker.java +++ b/src/rawDeepLearningClassifier/dlClassification/genericModel/GenericModelWorker.java @@ -18,7 +18,7 @@ import rawDeepLearningClassifier.dlClassification.animalSpot.StandardModelParams * @author Jamie Macaulay * */ -public class GenericModelWorker extends DLModelWorker { +public class GenericModelWorker extends DLModelWorker { /** * The generic model @@ -52,8 +52,8 @@ public class GenericModelWorker extends DLModelWorker { } @Override - public GenericPrediction makeModelResult(float[] prob, double time) { - GenericPrediction model = new GenericPrediction(prob); + public StandardPrediction makeModelResult(float[] prob, double time) { + StandardPrediction model = new StandardPrediction(prob); model.setAnalysisTime(time); return model; } diff --git a/src/rawDeepLearningClassifier/dlClassification/genericModel/GenericPrediction.java b/src/rawDeepLearningClassifier/dlClassification/genericModel/StandardPrediction.java similarity index 90% rename from src/rawDeepLearningClassifier/dlClassification/genericModel/GenericPrediction.java rename to src/rawDeepLearningClassifier/dlClassification/genericModel/StandardPrediction.java index 57e83218..b2f93dd7 100644 --- a/src/rawDeepLearningClassifier/dlClassification/genericModel/GenericPrediction.java +++ b/src/rawDeepLearningClassifier/dlClassification/genericModel/StandardPrediction.java @@ -9,7 +9,7 @@ import rawDeepLearningClassifier.dlClassification.PredictionResult; * @author Jamie Macaulay * */ -public class GenericPrediction implements PredictionResult { +public class StandardPrediction implements PredictionResult { /** @@ -45,14 +45,14 @@ public class GenericPrediction implements PredictionResult { * @param classNameID - the ID's of the class names. * @param isBinary - true if the model result passed a binary test (usually one species above a threshold) */ - public GenericPrediction(float[] prob, short[] classNameID, boolean isBinary) { + public StandardPrediction(float[] prob, short[] classNameID, boolean isBinary) { this.prob=prob; this.classNameID = classNameID; this.binaryPass= isBinary; } - public GenericPrediction(float[] prob, boolean isBinary) { + public StandardPrediction(float[] prob, boolean isBinary) { this(prob, null, isBinary); } @@ -60,7 +60,7 @@ public class GenericPrediction implements PredictionResult { * Create a result for the Sound Spot classifier. * @param prob - the probability of each class. */ - public GenericPrediction(float[] prob) { + public StandardPrediction(float[] prob) { this(prob, null, false); } diff --git a/src/rawDeepLearningClassifier/dlClassification/ketos/KetosClassifier.java b/src/rawDeepLearningClassifier/dlClassification/ketos/KetosClassifier.java index 437f8250..d224a013 100644 --- a/src/rawDeepLearningClassifier/dlClassification/ketos/KetosClassifier.java +++ b/src/rawDeepLearningClassifier/dlClassification/ketos/KetosClassifier.java @@ -14,7 +14,7 @@ import rawDeepLearningClassifier.dlClassification.DLClassiferModel; import rawDeepLearningClassifier.dlClassification.StandardClassifierModel; import rawDeepLearningClassifier.dlClassification.animalSpot.StandardModelParams; import rawDeepLearningClassifier.dlClassification.genericModel.DLModelWorker; -import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction; +import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; import rawDeepLearningClassifier.layoutFX.DLCLassiferModelUI; /** @@ -77,7 +77,7 @@ public class KetosClassifier extends StandardClassifierModel { @Override - public DLModelWorker getDLWorker() { + public DLModelWorker getDLWorker() { return getKetosWorker(); } diff --git a/src/rawDeepLearningClassifier/dlClassification/ketos/KetosResult.java b/src/rawDeepLearningClassifier/dlClassification/ketos/KetosResult.java index 510c311d..ca4777ff 100644 --- a/src/rawDeepLearningClassifier/dlClassification/ketos/KetosResult.java +++ b/src/rawDeepLearningClassifier/dlClassification/ketos/KetosResult.java @@ -1,6 +1,6 @@ package rawDeepLearningClassifier.dlClassification.ketos; -import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction; +import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; /** @@ -8,7 +8,7 @@ import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction * @author Jamie Macaulay * */ -public class KetosResult extends GenericPrediction { +public class KetosResult extends StandardPrediction { public KetosResult(float[] prob) { diff --git a/src/rawDeepLearningClassifier/dlClassification/ketos/KetosWorker.java b/src/rawDeepLearningClassifier/dlClassification/ketos/KetosWorker.java index 3a937c1b..a42422db 100644 --- a/src/rawDeepLearningClassifier/dlClassification/ketos/KetosWorker.java +++ b/src/rawDeepLearningClassifier/dlClassification/ketos/KetosWorker.java @@ -15,7 +15,7 @@ import PamView.dialog.warn.WarnOnce; import rawDeepLearningClassifier.DLControl; import rawDeepLearningClassifier.dlClassification.animalSpot.StandardModelParams; import rawDeepLearningClassifier.dlClassification.genericModel.DLModelWorker; -import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction; +import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; /** * @@ -25,7 +25,7 @@ import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction * @author Jamie Macaulay * */ -public class KetosWorker extends DLModelWorker { +public class KetosWorker extends DLModelWorker { /** diff --git a/src/rawDeepLearningClassifier/dlClassification/koogu/KooguClassifier.java b/src/rawDeepLearningClassifier/dlClassification/koogu/KooguClassifier.java index 411d6551..df7e049a 100644 --- a/src/rawDeepLearningClassifier/dlClassification/koogu/KooguClassifier.java +++ b/src/rawDeepLearningClassifier/dlClassification/koogu/KooguClassifier.java @@ -4,7 +4,7 @@ import rawDeepLearningClassifier.DLControl; import rawDeepLearningClassifier.dlClassification.archiveModel.ArchiveModelClassifier; import rawDeepLearningClassifier.dlClassification.archiveModel.ArchiveModelWorker; import rawDeepLearningClassifier.dlClassification.genericModel.DLModelWorker; -import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction; +import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; /** * Classifier which uses deep learning models from Koogus' framework. diff --git a/src/rawDeepLearningClassifier/logging/ModelResultBinaryFactory.java b/src/rawDeepLearningClassifier/logging/ModelResultBinaryFactory.java index 91b10536..84a56dee 100644 --- a/src/rawDeepLearningClassifier/logging/ModelResultBinaryFactory.java +++ b/src/rawDeepLearningClassifier/logging/ModelResultBinaryFactory.java @@ -8,7 +8,7 @@ import PamUtils.PamArrayUtils; import rawDeepLearningClassifier.dlClassification.PredictionResult; import rawDeepLearningClassifier.dlClassification.animalSpot.SoundSpotResult; import rawDeepLearningClassifier.dlClassification.dummyClassifier.DummyModelResult; -import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction; +import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; import rawDeepLearningClassifier.dlClassification.ketos.KetosResult; /** @@ -146,7 +146,7 @@ public class ModelResultBinaryFactory { break; default: //ideally should never be used. - result = new GenericPrediction(data, isBinary); + result = new StandardPrediction(data, isBinary); break; } //System.out.println("New model result: "+ type); @@ -173,7 +173,7 @@ public class ModelResultBinaryFactory { return KETOS; } //must be last because this is often sub classed - if (modelResult instanceof GenericPrediction) { + if (modelResult instanceof StandardPrediction) { return GENERIC; } if (modelResult instanceof DummyModelResult) { diff --git a/src/rawDeepLearningClassifier/segmenter/SegmenterDetectionGroup.java b/src/rawDeepLearningClassifier/segmenter/SegmenterDetectionGroup.java index 1a00c4a3..b41b3083 100644 --- a/src/rawDeepLearningClassifier/segmenter/SegmenterDetectionGroup.java +++ b/src/rawDeepLearningClassifier/segmenter/SegmenterDetectionGroup.java @@ -19,9 +19,16 @@ public class SegmenterDetectionGroup extends GroupDetection { * @param startSample - the stratSample of the SEGMENT. * @param duration - the duration of the SEGMENT. */ - public SegmenterDetectionGroup(long timeMilliseconds, int channelBitmap, long startSample, long duration) { - super(timeMilliseconds, channelBitmap, startSample, duration); - // TODO Auto-generated constructor stub + public SegmenterDetectionGroup(long timeMilliseconds, int channelBitmap, long startSample, double duration) { + super(timeMilliseconds, channelBitmap, startSample, (long) duration); + this.setDurationInMilliseconds(duration); + } + + @Override + public boolean isAllowSubdetectionSharing() { + //segmetns share sub detections + return true; } + } diff --git a/src/rawDeepLearningClassifier/segmenter/SegmenterGroupDataBlock.java b/src/rawDeepLearningClassifier/segmenter/SegmenterGroupDataBlock.java index cbd18e3a..3bda33fd 100644 --- a/src/rawDeepLearningClassifier/segmenter/SegmenterGroupDataBlock.java +++ b/src/rawDeepLearningClassifier/segmenter/SegmenterGroupDataBlock.java @@ -12,7 +12,7 @@ public class SegmenterGroupDataBlock extends PamDataBlock gwenericPrediciton = genericModelWorker.runModel(groupedData, soundData.sampleRate, 0); + ArrayList gwenericPrediciton = genericModelWorker.runModel(groupedData, soundData.sampleRate, 0); float[] output = gwenericPrediciton.get(0).getPrediction(); @@ -165,7 +165,7 @@ public class GenericDLClassifierTest { groupedData.add(groupedRawData); - ArrayList genericPrediction = genericModelWorker.runModel(groupedData, soundData.sampleRate, 0); + ArrayList genericPrediction = genericModelWorker.runModel(groupedData, soundData.sampleRate, 0); float[] output = genericPrediction.get(0).getPrediction(); diff --git a/src/test/rawDeepLearningClassifier/KetosDLClassifierTest.java b/src/test/rawDeepLearningClassifier/KetosDLClassifierTest.java index b898810b..fc590764 100644 --- a/src/test/rawDeepLearningClassifier/KetosDLClassifierTest.java +++ b/src/test/rawDeepLearningClassifier/KetosDLClassifierTest.java @@ -13,7 +13,7 @@ import javax.sound.sampled.UnsupportedAudioFileException; import org.jamdev.jdl4pam.utils.DLUtils; import org.jamdev.jpamutils.wavFiles.AudioData; -import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction; +import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; import rawDeepLearningClassifier.dlClassification.ketos.KetosDLParams; import rawDeepLearningClassifier.dlClassification.ketos.KetosWorker2; import rawDeepLearningClassifier.segmenter.GroupedRawData; @@ -140,7 +140,7 @@ public class KetosDLClassifierTest { ArrayList groupedData = new ArrayList(); groupedData.add(groupedRawData); - ArrayList genericPrediciton = ketosWorker2.runModel(groupedData, soundData.sampleRate, 0); + ArrayList genericPrediciton = ketosWorker2.runModel(groupedData, soundData.sampleRate, 0); float[] output = genericPrediciton.get(0).getPrediction(); boolean testPassed= output[1]> ketosPredicitons[i][2]-0.1 && output[1]< ketosPredicitons[i][2]+0.1; diff --git a/src/test/rawDeepLearningClassifier/KooguDLClassifierTest.java b/src/test/rawDeepLearningClassifier/KooguDLClassifierTest.java index 6a13ec46..e3ea9c5b 100644 --- a/src/test/rawDeepLearningClassifier/KooguDLClassifierTest.java +++ b/src/test/rawDeepLearningClassifier/KooguDLClassifierTest.java @@ -16,7 +16,7 @@ import org.jamdev.jpamutils.wavFiles.AudioData; import org.junit.jupiter.api.Test; import rawDeepLearningClassifier.dlClassification.animalSpot.StandardModelParams; -import rawDeepLearningClassifier.dlClassification.genericModel.GenericPrediction; +import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; import rawDeepLearningClassifier.dlClassification.koogu.KooguModelWorker; import rawDeepLearningClassifier.segmenter.GroupedRawData; import us.hebi.matlab.mat.format.Mat5; @@ -102,7 +102,7 @@ public class KooguDLClassifierTest { groupedData.add(groupedRawData); - ArrayList genericPrediciton = kooguWorker.runModel(groupedData, soundData.sampleRate, 0); + ArrayList genericPrediciton = kooguWorker.runModel(groupedData, soundData.sampleRate, 0); float[] output = genericPrediciton.get(0).getPrediction(); boolean testPassed= output[1]> kooguPredicitions[i][2]-0.1 && output[1]< kooguPredicitions[i][2]+0.1; diff --git a/src/tethys/localization/LocalizationHandler.java b/src/tethys/localization/LocalizationHandler.java index 69105b5e..3751df93 100644 --- a/src/tethys/localization/LocalizationHandler.java +++ b/src/tethys/localization/LocalizationHandler.java @@ -1,17 +1,17 @@ package tethys.localization; -import nilus.CylindricalCoordinateType; -import nilus.LocalizationType; -import nilus.Localize.Effort.CoordinateReferenceSystem; +//import nilus.CylindricalCoordinateType; +//import nilus.LocalizationType; +//import nilus.Localize.Effort.CoordinateReferenceSystem; public class LocalizationHandler { - public LocalizationType getLoc() { - LocalizationType lt = new LocalizationType(); - CylindricalCoordinateType cct = new CylindricalCoordinateType(); -// cct.set - CoordinateReferenceSystem cr; - return null; - } +// public LocalizationType getLoc() { +// LocalizationType lt = new LocalizationType(); +// CylindricalCoordinateType cct = new CylindricalCoordinateType(); +//// cct.set +// CoordinateReferenceSystem cr; +// return null; +// } }