Class OrcaSpotWorkerExe2
java.lang.Object
rawDeepLearningClassifier.dlClassification.orcaSpot.OrcaSpotWorkerExe2
Executes the Orca Spot deep learning classifier from a python.exe file and
python scripts.
conda install win32pipe, win32file, pywintypes
A temporary wav file is written from current audio data. Python code is then executed which reads the python.exe file and runs scripts which us a deep learning model to detect whether there is an Orca in the audio data. A result is then returned.
This a clunky way of doing this however serves as a prototype for a more integrated approach in future.
Prerequisites
- The OrcaSpot folder with required scripts and models. Script paths are located in OrcaSpotParmas
- Python and Anaconda or similar installed.
- Cuda installed from Nvidea.
- Cuda support for Pytorch installed. To set up the python environment properly
- Open command prompt or Anaconda prompt if is using Anaconda.
- Type python -m venv C:\Your\Enviroment\Path\Here for Example python -m venv C:\Users\Hauec\Desktop\Segmenter\pytorch\my-venv. This creates a Folder called my-venv in the PyTorch Folder inside of the Segmenter.
- Next you need to activate your Virtual environment. Inside of my-venv\Scripts should see a windows batch called activate.bat. cd to it and run it in CMD. You'll know that it is active via the (my-venv) precommand.
- Once that is done, run setup_pytorch.bat from the PyTorch folder. It should automatically install Pytorch, PyVision, and all of the required dependencies. With the exception of pywin32 and pypiwin32. Both of them need to installed manually through pip. e.g. pip install pywin32, pypiwin32
To get the daemon to run properly you must also install C:\Users\macst>conda install win32pipe e.g. in Anaconda this is:
- Author:
- Christopher Hauer, Jamie Macaulay
-
Constructor Summary
ConstructorDescriptionOrcaSpotWorkerExe2
(OrcaSpotParams2 orcaSpotParams2) Constructor for OrcaSpot classifier Creates OrcaSpot Daemon -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
createDetectorDaemon
(boolean cuda) Create our Background Process and establish connection.boolean
Check whether the output indicates this is an orca or not.static void
Test the algorithm!Read Input from DaemonProcess.runOrcaSpot
(double[] data) Run OrcaSpot and return a resultrunOrcaSpot
(File audioFile) Run orca spotstatic double[]
transformAudio2Double
(File audiofile) Transforms Audiodata to doubles
-
Constructor Details
-
OrcaSpotWorkerExe2
Constructor for OrcaSpot classifier Creates OrcaSpot Daemon
-
-
Method Details
-
createDetectorDaemon
public void createDetectorDaemon(boolean cuda) Create our Background Process and establish connection.- Parameters:
cuda
-
-
closeOrcaSpotWorker
public void closeOrcaSpotWorker() -
transformAudio2Double
public static double[] transformAudio2Double(File audiofile) throws UnsupportedAudioFileException, IOException Transforms Audiodata to doubles- Parameters:
audiofile
- - the audio file to import- Returns:
- the raw audio dtaa.
- Throws:
UnsupportedAudioFileException
IOException
-
readPrediction
Read Input from DaemonProcess.- Throws:
IOException
-
runOrcaSpot
public OrcaSpotModelResult runOrcaSpot(File audioFile) throws IOException, UnsupportedAudioFileException Run orca spot -
runOrcaSpot
Run OrcaSpot and return a result- Parameters:
data
- - raw acoustic data.- Returns:
- Throws:
IOException
-
is_orca
Check whether the output indicates this is an orca or not.- Parameters:
prediction_line
- - the prediction string from the classifier output/- Returns:
- true if an orca is classified.
-
main
Test the algorithm!- Parameters:
args
- - input arguments- Throws:
UnsupportedAudioFileException
IOException
-