mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2025-04-28 02:57:22 +00:00
Minor updates to tests
This commit is contained in:
parent
93ec5fb090
commit
c2a886421a
@ -71,7 +71,8 @@ public class MultiSpeciesGoogle implements DLModel {
|
|||||||
//create the transforms.
|
//create the transforms.
|
||||||
ArrayList<DLTransfromParams> dlTransformParamsArr = new ArrayList<DLTransfromParams>();
|
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;
|
genericModelParams.dlTransfromParams = dlTransformParamsArr;
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package test.export;
|
|||||||
import test.helper.PamControllerTestHelper;
|
import test.helper.PamControllerTestHelper;
|
||||||
import clickDetector.ClickControl;
|
import clickDetector.ClickControl;
|
||||||
import clickDetector.ClickDetector;
|
import clickDetector.ClickDetector;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import clickDetector.ClickDetection;
|
import clickDetector.ClickDetection;
|
||||||
@ -21,7 +22,7 @@ public class ExportTest {
|
|||||||
public void matFileTest() throws Exception {
|
public void matFileTest() throws Exception {
|
||||||
PamControllerTestHelper.InitializePamControllerForTesting();
|
PamControllerTestHelper.InitializePamControllerForTesting();
|
||||||
|
|
||||||
System.out.println("Matched template classifier test: match corr");
|
System.out.println("Export MATLAB TEST");
|
||||||
|
|
||||||
//create a list of click detections.
|
//create a list of click detections.
|
||||||
ClickControl control = new ClickControl("name");
|
ClickControl control = new ClickControl("name");
|
||||||
|
@ -12,6 +12,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
public class OneBandControlTest {
|
public class OneBandControlTest {
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public static void setUpBeforeClass() throws Exception {
|
||||||
PamControllerTestHelper.InitializePamControllerForTesting();
|
PamControllerTestHelper.InitializePamControllerForTesting();
|
||||||
|
@ -92,7 +92,7 @@ public class KooguDLClassifierTest {
|
|||||||
|
|
||||||
GroupedRawData groupedRawData = new GroupedRawData(0, 1, 0, duration, (int) duration);
|
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
|
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>();
|
ArrayList<GroupedRawData> groupedData = new ArrayList<GroupedRawData>();
|
||||||
groupedData.add(groupedRawData);
|
groupedData.add(groupedRawData);
|
||||||
|
|
||||||
|
|
||||||
ArrayList<StandardPrediction> genericPrediciton = kooguWorker.runModel(groupedData, soundData.sampleRate, 0);
|
ArrayList<StandardPrediction> genericPrediciton = kooguWorker.runModel(groupedData, soundData.sampleRate, 0);
|
||||||
float[] output = genericPrediciton.get(0).getPrediction();
|
float[] output = genericPrediciton.get(0).getPrediction();
|
||||||
|
|
||||||
@ -113,12 +112,14 @@ public class KooguDLClassifierTest {
|
|||||||
if (testPassed) {
|
if (testPassed) {
|
||||||
truecount++;
|
truecount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//there are occasionaly slight differences between PMAGuard and Python so just make sure most data points are the same.
|
//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;
|
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
|
//at least 90% of results must match for the dataset
|
||||||
assertTrue(percTrue>0.9);
|
assertTrue(percTrue>0.9);
|
||||||
|
@ -8,8 +8,6 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
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.DLMatFile;
|
||||||
import org.jamdev.jdl4pam.utils.DLUtils;
|
import org.jamdev.jdl4pam.utils.DLUtils;
|
||||||
import org.jamdev.jpamutils.wavFiles.AudioData;
|
import org.jamdev.jpamutils.wavFiles.AudioData;
|
||||||
@ -182,7 +180,11 @@ public class PamZipDLClassifierTest {
|
|||||||
|
|
||||||
//path to the same file at different sample rates
|
//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 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 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";
|
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 multiSpeciesGoogle = new MultiSpeciesGoogle();
|
||||||
multiSpeciesGoogle.setParams(genericModelParams);
|
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);
|
System.out.println(genericModelParams);
|
||||||
|
|
||||||
double segSize = 5.; //one second hop size.
|
double segSize = 5.; //one second hop size.
|
||||||
double segHop = 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.
|
//create MatFile for saving the image data to.
|
||||||
MatFile matFile = Mat5.newMatFile();
|
MatFile matFile = Mat5.newMatFile();
|
||||||
@ -227,9 +229,12 @@ public class PamZipDLClassifierTest {
|
|||||||
|
|
||||||
//load audio
|
//load audio
|
||||||
AudioData soundData = DLUtils.loadWavFile(wavFilePath);
|
AudioData soundData = DLUtils.loadWavFile(wavFilePath);
|
||||||
|
|
||||||
|
//TEMP
|
||||||
// if (i==1) {
|
// if (i==1) {
|
||||||
// soundData=soundData.interpolate(24000);
|
// soundData=soundData.interpolate(24000);
|
||||||
// }
|
// }
|
||||||
|
//////
|
||||||
|
|
||||||
int nseg = (int) (soundData.samples.length/(segHop*soundData.sampleRate));
|
int nseg = (int) (soundData.samples.length/(segHop*soundData.sampleRate));
|
||||||
float[][] outputs = new float[nseg][];
|
float[][] outputs = new float[nseg][];
|
||||||
|
Loading…
Reference in New Issue
Block a user