Bug fixes

Fixed wav file export bug from TDDisplayFX
Fixed bug in deep learning classifier where binary classification was not saving properly for generic models.
This commit is contained in:
Jamie Mac 2024-04-19 10:18:28 +01:00
parent a1adff82cb
commit 65bbcdeb96
9 changed files with 35 additions and 21 deletions

View File

@ -6,7 +6,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/Amazon Coretto 21">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-21.0.2.13-hotspot">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>

View File

@ -1155,7 +1155,7 @@ public class TDGraphFX extends PamBorderPane {
base = false;
if (!dataInfo.isShowing()) {
System.out.println("!dataInfo.isShowing(): " + dataInfo.getDataName());
//System.out.println("!dataInfo.isShowing(): " + dataInfo.getDataName());
continue;
}

View File

@ -186,7 +186,6 @@ public abstract class RawDataOrder {
*/
public boolean resetForLoad(long dataStart, long dataEnd, float sampleRate, int channel) {
// System.out.println("RESET FOR LOAD: ");
count=0;
this.dataStart=dataStart;
this.dataEnd=dataEnd;
@ -194,6 +193,8 @@ public abstract class RawDataOrder {
this.fftSampleRate=sampleRate;
int dataFrame=(int) (sampleRate*((dataEnd-dataStart)/1000.));
// System.out.println("RESET FOR LOAD: " + dataFrame);
if (dataFrame>=maxMb){
System.err.println("The raw data is way too big");
@ -213,12 +214,13 @@ public abstract class RawDataOrder {
}
private int currentIndex=0;
/***
* Called whenever new raw data is acquired
* @param dataUnit
*/
private void newRawData(RawDataUnit dataUnit) {
// System.out.println("New raw data " + count);
// System.out.println("New raw data " + count);
// try{
if (PamUtils.hasChannel(dataUnit.getChannelBitmap(), channel)){

View File

@ -146,7 +146,7 @@ public class WavFileExportManager implements PamDataUnitExporter {
//add correct file type.
currentPath = currentPath + ".wav";
currentPath = currentFolder+"/"+currentPath;
currentPath = currentFolder + File.pathSeparator + currentPath;
return currentPath;
@ -197,7 +197,7 @@ public class WavFileExportManager implements PamDataUnitExporter {
if (foundDataUnits!=null) {
//check whether the wav file has all data raw data units.
int n = getNWavDataUnits(foundDataUnits);
hasAllWavClips = n == foundDataUnits.getNumDataUnits();
hasAllWavClips = (n == foundDataUnits.getNumDataUnits() && n!=0); //make sure to do a zero check here or raw wav data won't save
System.out.println("N raw data units: " + n + " N found data units: " + foundDataUnits.getNumDataUnits());
}
@ -234,7 +234,6 @@ public class WavFileExportManager implements PamDataUnitExporter {
rawDataBlock.orderOfflineData(new RawObserver(wavWrite, rawDataBlock.getChannelMap()), new RawLoadObserver(wavWrite),
start, end, 1, OfflineDataLoading.OFFLINE_DATA_INTERRUPT);
return 0;
}
@ -292,7 +291,7 @@ public class WavFileExportManager implements PamDataUnitExporter {
* @param dataUnit
*/
private void newRawData(RawDataUnit dataUnit) {
// System.out.println(" Time millis: "+ dataUnit.getTimeMilliseconds()+ " channel: " + PamUtils.getSingleChannel(dataUnit.getChannelBitmap()) );
// System.out.println("Write wav data: Time millis: "+ dataUnit.getTimeMilliseconds()+ " channel: " + PamUtils.getSingleChannel(dataUnit.getChannelBitmap()) );
if (currentTimeMillis!=dataUnit.getTimeMilliseconds()) {
currentTimeMillis=dataUnit.getTimeMilliseconds();
if (wavArray!=null) {

View File

@ -277,7 +277,7 @@ public abstract class StandardClassifierModel implements DLClassiferModel, PamSe
}
@Deprecated
public static ArrayList<PamWarning> checkSettingsOK(StandardModelParams genericModelParams, DLControl dlControl) {
// TODO - check if model is null.

View File

@ -18,6 +18,7 @@ import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.Spinner;
import javafx.scene.control.Tooltip;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
@ -191,9 +192,12 @@ public abstract class StandardModelPane extends SettingsPane<StandardModelParams
gridPane.add(new Label("Min. prediction"), 0, 0);
gridPane.add(detectionSpinner = new PamSpinner<Double>(0.0, 1.0, 0.9, 0.1), 1, 0);
detectionSpinner.setPrefWidth(80);
detectionSpinner.setPrefWidth(70);
detectionSpinner.setEditable(true);
detectionSpinner.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL);
detectionSpinner.setTooltip(new Tooltip("Set the minimum prediciton value for selected classes. If a prediction exceeds this value "
+ "a detection will be saved."));
gridPane.add(new Label(""), 2, 0);
speciesIDBox = new CheckComboBox<String>();
@ -201,8 +205,9 @@ public abstract class StandardModelPane extends SettingsPane<StandardModelParams
//speciesIDBox.setMaxWidth(100);
// speciesIDBox.setPrefWidth(100);
speciesIDBox.prefHeightProperty().bind(detectionSpinner.heightProperty());
speciesIDBox.setMaxWidth(200); //otherwise expands too much if multiple classes selected
speciesIDBox.setMaxWidth(150); //otherwise expands too much if multiple classes selected
speciesIDBox.setTooltip(new Tooltip("Select output classes to use for binary classification. "
+ "If the prediction value of a selected class exceeds the minimum prediction threshold then a detection is saved. "));
validator = new PamValidator();
final SimpleIntegerProperty checkItemsCount = new SimpleIntegerProperty();
@ -330,7 +335,7 @@ public abstract class StandardModelPane extends SettingsPane<StandardModelParams
currParams.threshold = detectionSpinner.getValue();
// currParams.useCUDA = useCuda.isSelected();
// System.out.println("StandardModelParams : this.paramsClone.numClasses " + this.paramsClone.numClasses);
// System.out.println("GET PARAMS: StandardModelParams : this.paramsClone.numClasses " + this.paramsClone.numClasses);
boolean[] speciesClass = new boolean[this.paramsClone.numClasses];
@ -363,7 +368,6 @@ public abstract class StandardModelPane extends SettingsPane<StandardModelParams
// System.out.println("GET CLASS NAMES: currParams.classNames: " + currParams.classNames + " " +
// (currParams.classNames!=null? currParams.classNames.length: 0 + " " + currParams.numClasses));
currParams.useDefaultSegLen = usedefaultSeg.isSelected();
//System.out.println("Get CLASS NAMES: currParams.classNames: " + currParams.classNames + " Num classes " + currParams.numClasses);

View File

@ -11,7 +11,6 @@ import org.jamdev.jdl4pam.transforms.DLTransformsFactory;
import org.jamdev.jdl4pam.utils.DLUtils;
import org.jamdev.jpamutils.wavFiles.AudioData;
import PamUtils.PamArrayUtils;
import rawDeepLearningClassifier.DLControl;
import rawDeepLearningClassifier.dlClassification.animalSpot.StandardModelParams;
import rawDeepLearningClassifier.segmenter.SegmenterProcess.GroupedRawData;
@ -126,7 +125,7 @@ public abstract class DLModelWorker<T> {
float[] classOut;
for (int i=0; i<transformedDataStack.length; i++) {
/**
* This is super weird. Reading the documentation for copeOfRange the index from and index to are enclusive. So
* This is super weird. Reading the documentation for copyOfRange the index from and index to are inclusive. So
* to copy the first two elements indexfrom =0 and indexto = 1. But actually it seems that this should be indexfrom =0 and indexto =2.
* So do not minus one form (i+1)*numclasses. This works but I'm confused as to why?
*/

View File

@ -75,17 +75,26 @@ public class GenericModelPane extends StandardModelPane {
super.setParams(currParams);
}
@Override
public StandardModelParams getParams(StandardModelParams currParams) {
// System.out.println("GET GENERIC PARAMS: " + currParams);
return super.getParams(currParams);
}
@Override
public void newModelSelected(File file) {
this.setCurrentSelectedFile(file);
//this.setParamsClone(new GenericModelParams());
//prep the model with current parameters;
genericDLClassifier.getGenericDLWorker().prepModel(getParams(getParamsClone()), genericDLClassifier.getDLControl());
//get the model transforms calculated from the model by SoundSpoyWorker and apply them to our temporary paramters clone.
//getParamsClone().dlTransfroms = this.genericDLClassifier.getGenericDLWorker().getModelTransforms();
///set the advanced pane parameters.
// genericDLClassifier.getGenericDLWorker().prepModel(getParams(getParamsClone()), genericDLClassifier.getDLControl());
//do not have getParam here as it resets some of the setting before set params has been called.
genericDLClassifier.getGenericDLWorker().prepModel(getParamsClone(), genericDLClassifier.getDLControl());
//now new parameters have been set in the prepModel functions so need to set new params now.
getAdvSettingsPane().setParams(getParamsClone());

View File

@ -454,6 +454,7 @@ public class DLSettingsPane extends SettingsPane<RawDLParams>{
// }
currParams.useDataSelector = dataSelectorCheckBox.isSelected();
if (dlControl.getDataSelector()!=null) {
dlControl.getDataSelector().getDialogPaneFX().getParams(true);
}