Minor updates to tests

This commit is contained in:
Jamie Mac 2025-03-11 15:35:34 +00:00
parent 93ec5fb090
commit c2a886421a
5 changed files with 19 additions and 10 deletions

View File

@ -71,7 +71,8 @@ public class MultiSpeciesGoogle implements DLModel {
//create the transforms.
ArrayList<DLTransfromParams> dlTransformParamsArr = new ArrayList<DLTransfromParams>();
dlTransformParamsArr.add(new SimpleTransformParams(DLTransformType.DECIMATE_SCIPY, sr));
//Performed long series of test son which decimator is best for upsampling and it is, by far, the DECIMATE transform.
dlTransformParamsArr.add(new SimpleTransformParams(DLTransformType.DECIMATE, sr));
genericModelParams.dlTransfromParams = dlTransformParamsArr;

View File

@ -3,6 +3,7 @@ package test.export;
import test.helper.PamControllerTestHelper;
import clickDetector.ClickControl;
import clickDetector.ClickDetector;
import org.junit.jupiter.api.Test;
import clickDetector.ClickDetection;
@ -21,7 +22,7 @@ public class ExportTest {
public void matFileTest() throws Exception {
PamControllerTestHelper.InitializePamControllerForTesting();
System.out.println("Matched template classifier test: match corr");
System.out.println("Export MATLAB TEST");
//create a list of click detections.
ClickControl control = new ClickControl("name");

View File

@ -12,6 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class OneBandControlTest {
@BeforeAll
public static void setUpBeforeClass() throws Exception {
PamControllerTestHelper.InitializePamControllerForTesting();

View File

@ -92,7 +92,7 @@ public class KooguDLClassifierTest {
GroupedRawData groupedRawData = new GroupedRawData(0, 1, 0, duration, (int) duration);
//koogu predictions are in sam,ples
//koogu predictions are in samples
int startChunk =(int) (kooguPredicitions[i][0]*soundData.sampleRate/250); ///the start chunk is in decimated samples - uuurgh
@ -101,7 +101,6 @@ public class KooguDLClassifierTest {
ArrayList<GroupedRawData> groupedData = new ArrayList<GroupedRawData>();
groupedData.add(groupedRawData);
ArrayList<StandardPrediction> genericPrediciton = kooguWorker.runModel(groupedData, soundData.sampleRate, 0);
float[] output = genericPrediciton.get(0).getPrediction();
@ -113,12 +112,14 @@ public class KooguDLClassifierTest {
if (testPassed) {
truecount++;
}
}
//there are occasionaly slight differences between PMAGuard and Python so just make sure most data points are the same.
double percTrue = 100*((double) truecount)/kooguPredicitions.length;
System.out.println(String.format("Perecentage results true: %.2f count %d", percTrue, truecount));
System.out.println(String.format("Percentage results true: %.2f count %d", percTrue, truecount));
//at least 90% of results must match for the dataset
assertTrue(percTrue>0.9);

View File

@ -8,8 +8,6 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import org.jamdev.jdl4pam.transforms.DLTransform.DLTransformType;
import org.jamdev.jdl4pam.transforms.SimpleTransformParams;
import org.jamdev.jdl4pam.utils.DLMatFile;
import org.jamdev.jdl4pam.utils.DLUtils;
import org.jamdev.jpamutils.wavFiles.AudioData;
@ -182,7 +180,11 @@ public class PamZipDLClassifierTest {
//path to the same file at different sample rates
String relWavPath = "./src/test/resources/rawDeepLearningClassifier/Generic/multi-species-Google/NOPP6_EST_20090329_121500.wav";
String relWavPath2 = "./src/test/resources/rawDeepLearningClassifier/Generic/multi-species-Google/NOPP6_EST_20090329_121500_upsample.wav";
String relWavPath2 = "./src/test/resources/rawDeepLearningClassifier/Generic/multi-species-Google/NOPP6_EST_20090329_121500_upsample_pg.wav";
/**
* Test up-sampling using audio then downsampling agian
*/
// String relWavPath2 = "./src/test/resources/rawDeepLearningClassifier/Generic/multi-species-Google/NOPP6_EST_20090329_121500.wav";
String matFileOut = "/Users/jdjm/MATLAB-Drive/MATLAB/PAMGUARD/deep_learning/google_multi_species/google_multi_species.mat";
@ -202,13 +204,13 @@ public class PamZipDLClassifierTest {
MultiSpeciesGoogle multiSpeciesGoogle = new MultiSpeciesGoogle();
multiSpeciesGoogle.setParams(genericModelParams);
genericModelParams.dlTransfromParams.set(0, new SimpleTransformParams(DLTransformType.DECIMATE, 24000.));
//genericModelParams.dlTransfromParams.set(0, new SimpleTransformParams(DLTransformType.DECIMATE, 24000.));
System.out.println(genericModelParams);
double segSize = 5.; //one second hop size.
double segHop = 5.; //one second hop size.
int classIndex = 5; //Right whale atlantic - jus for output
int classIndex = 5; //Right whale atlantic - just for output
//create MatFile for saving the image data to.
MatFile matFile = Mat5.newMatFile();
@ -227,9 +229,12 @@ public class PamZipDLClassifierTest {
//load audio
AudioData soundData = DLUtils.loadWavFile(wavFilePath);
//TEMP
// if (i==1) {
// soundData=soundData.interpolate(24000);
// }
//////
int nseg = (int) (soundData.samples.length/(segHop*soundData.sampleRate));
float[][] outputs = new float[nseg][];