Class DLControl
- All Implemented Interfaces:
PamSettings
,SettingsNameProvider
For example, the module can be used to apply a deep learning model to analyse raw sound data, clips or click detections.
The module is essentially a PAMGuard wrapper for the jdl4pam library which does most of the working in loading models and setting up spectrogram transforms so models receive the correct input data. The majority of the code for the module involves interfacing with PAMGuard's data management system (e.g. binary files), visualisation tools such as spectrogram graphics and the TDDisplayFX and creating a settings GUI so users can load models easily and visualise how they work.
Currently the jdl4pam library supports three types of deep learning model, Generic, AnimalSpot and Ketos.
Generic
Generic models allows users to load almost any type of model and manually
assign the types of data transform and input shape. This means that the user
has to get the settings exactly right or the model will not work. It is the
most complex way to run a deep learning model and generally not recommenced.
However, users can export a settings file which makes it easier to set up for
another user.
AnimalSpot
AnimalSpot is a framework for training acoustic deep learning
models using Pytorch. Users can load a .py model which contains embedded
metadata so that PMAGuard knows the exact transforms required for the model
input. This makes deploying models in PAMGuard very easy - users require little
or no experience to get this working.
Ketos
Ketos is a framework for training acoustic deep learning models
using TensorFlow. Users can load a .ktpb model which contains embedded
metadata so that PMAGuard knows the exact transforms required for the model
input. Like AnimalSpot, this makes deploying Ketos models in PAMGuard very
straightforward.
- Author:
- Jamie Macaulay
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Flag to indicate a setup is requiredstatic final boolean
PLUGIN_BUILD boolean is set to true so that the class loader isn't changed.static final int
static final int
Flag for processing start -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Called when setParams is called, which should have new model params after the dialog was closed.void
createDataSelector
(PamDataBlock<?> source) Get the data selector.createDetectionMenu
(Frame parentFrame) Create a JMenu object containing MenuItems associated with PamProcessesConvenience function to get the DLAnnotationType from the DLClassification process.The current data selector.Get the default model manager.Get the classifier chooser.Get the deep learning classification process.Get the current deep learning model.getDLModel
(String string) Get a model by it's name.Get the available deep learning modelsGet basic parameters.Get the download manager for downloading models offline.getGUI
(int flag) Get the GUI for the PAMControlled unit.int
Get the number of classes for the current classifier.Get the parent data block.Get the segmenter process.Get the settings pane.long
Gets a reference to a small panel to be displayed along the left hand edge of the main tab panel.boolean
restoreSettings
(PamControlledUnitSettings pamControlledUnitSettings) void
setParams
(RawDLParams newParams) void
showSettingsDialog
(Frame parentFrame) Show settings dialog.void
update
(int processingFlag) Called whenever offline processing is occurringMethods inherited from class PamController.PamControlledUnit
addOfflineTaskGroup, addOtherRelatedMenuItems, addPamProcess, addPamProcess, addRelatedMenuItems, canClose, canPlayViewerSound, createDisplayMenu, createFileMenu, createHelpMenu, flushDataBlockBuffers, getBackupInformation, getFrameNumber, getGuiFrame, getInstanceIndex, getModuleStatus, getModuleStatusManager, getModuleSummary, getModuleSummary, getNumOfflineTaskGroups, getNumPamProcesses, getOfflineState, getOfflineTaskGroup, getPamConfiguration, getPamController, getPamModuleInfo, getPamProcess, getPamView, getPlugin, getShortUnitType, getTabClipCopier, getTabPanel, getTabSpecificMenuBar, getToolbarComponent, getUnitName, getUnitType, getVerboseLevel, gotoTab, isInMainConfiguration, isNetRx, isViewer, notifyModelChanged, pamClose, pamHasStopped, pamToStart, playViewerSound, removePamProcess, removeUnit, rename, saveViewerData, setFrameNumber, setModuleStatusManager, setPamConfiguration, setPamController, setPamModuleInfo, setPamView, setSidePanel, setTabPanel, setToolbarComponent, setupControlledUnit, stopViewerSound, tellModule, terminalPrint, terminalPrintln, toString
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface PamController.PamSettings
getUnitType
Methods inherited from interface PamController.SettingsNameProvider
getUnitName
-
Field Details
-
PLUGIN_BUILD
public static final boolean PLUGIN_BUILDPLUGIN_BUILD boolean is set to true so that the class loader isn't changed. When ready to compile into a fatjar set to true. When using eclipse set to false.- See Also:
-
PROCESSING_START
public static final int PROCESSING_STARTFlag for processing start- See Also:
-
NEW_PARAMS
public static final int NEW_PARAMSFlag to indicate a setup is required- See Also:
-
PROCESSING_END
public static final int PROCESSING_END- See Also:
-
-
Constructor Details
-
DLControl
Constructor for the DL Control.- Parameters:
unitName
- - the unit name.
-
-
Method Details
-
getDLModels
Get the available deep learning models- Returns:
- the available deep learning models.
-
getDLModel
Get a model by it's name.- Parameters:
the
- name the model.- Returns:
- the corresponding model object or null if no model with the name exists.
-
getDLModel
Get the current deep learning model.- Returns:
- the current deep learning model.
-
getDLParams
Get basic parameters.- Returns:
- parameters class.
-
getSettingsReference
- Specified by:
getSettingsReference
in interfacePamSettings
- Returns:
- The serialisable object that will be stored
-
getSettingsVersion
public long getSettingsVersion()- Specified by:
getSettingsVersion
in interfacePamSettings
- Returns:
- An integer version number for the settings
-
restoreSettings
- Specified by:
restoreSettings
in interfacePamSettings
- Returns:
- true if successful The object performs final checks (if needed) and then casts the settings data pamcontrolledunitSettings.settings into the correct type and uses as required
-
getSegmenter
Get the segmenter process. This breaks raw data into chunks, combines into groups and sends to DL classifiers.- Returns:
- the segmenter process.
-
getSettingsPane
Get the settings pane.- Returns:
- the settings pane.
-
showSettingsDialog
Show settings dialog.- Parameters:
parentFrame
- - the frame.
-
getSidePanel
Description copied from class:PamControlledUnit
Gets a reference to a small panel to be displayed along the left hand edge of the main tab panel. Side panels should be small since they are always visible and any space they take will be taken from the main tab panel.It is possible for a PamControlled unit to have a side panel without having a pamTabPanel.
- Overrides:
getSidePanel
in classPamControlledUnit
- Returns:
- a pamSidePanel object.
- See Also:
-
createDetectionMenu
Description copied from class:PamControlledUnit
Create a JMenu object containing MenuItems associated with PamProcesses- Overrides:
createDetectionMenu
in classPamControlledUnit
- Parameters:
parentFrame
- The owner frame of the menu- Returns:
- reference to a JMenu which can be added to an existing menu or
menu bar
Note that if multiple views are to use the same menu, then they should each create a new menu (by setting Create to true) the first time they call this method.
-
getDLClassifyProcess
Get the deep learning classification process. This handles running the current deep learning model.- Returns:
- the deep learning classification process.
-
getGUI
Get the GUI for the PAMControlled unit. This has multiple GUI options which are instantiated depending on the view type.- Overrides:
getGUI
in classPamControlledUnit
- Parameters:
flag
- . The GUI type flag defined in PAMGuiManager.- Returns:
- the GUI for the PamControlledUnit unit.
-
setParams
-
checkModelParams
public void checkModelParams()Called when setParams is called, which should have new model params after the dialog was closed. Puts these into dlParams so they get serialised with rest of XML. -
getParentDataBlock
Get the parent data block.- Returns:
- the parent data block.
-
getNumClasses
public int getNumClasses()Get the number of classes for the current classifier.- Returns:
- the number of classes.
-
update
public void update(int processingFlag) Called whenever offline processing is occurring- Parameters:
processingFlag
-
-
getClassNameManager
-
getAnnotationType
Convenience function to get the DLAnnotationType from the DLClassification process.- Returns:
- the DLAnnotationType
-
getDataSelector
The current data selector.- Returns:
- the current data selector.
-
createDataSelector
Get the data selector.- Parameters:
source
- - the source data block
-
getDlClassifierChooser
Get the classifier chooser. The classifier chooser chooses which classifier use based on a selected file or URL.- Returns:
- the classifier chooser.
-
getDownloadManager
Get the download manager for downloading models offline.- Returns:
- the download manager.
-
getDefaultModelManager
Get the default model manager. This handles the default models that can be downloaded.- Returns:
- the default model manager.
-