Class DLControl
- All Implemented Interfaces:
ClipDisplayParent,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
FieldsModifier and TypeFieldDescriptionstatic final intFlag to indicate a setup is requiredstatic final booleanPLUGIN_BUILD boolean is set to true so that the class loader isn't changed.static final intstatic final intFlag for processing startFields inherited from class PamController.PamControlledUnit
isMixed, isViewer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled when setParams is called, which should have new model params after the dialog was closed.voidcreateDataSelector(PamDataBlock<?> source) Get the data selector.createDetectionMenu(Frame parentFrame) Create a JMenu object containing MenuItems associated with PamProcessesvoidConvenience function to get the DLAnnotationType from the DLClassification process.getClipDecorations(ClipDisplayUnit clipDisplayUnit) Add additional functionality and controls to a clip display unitThe current data selector.Get the default model manager.A name (though I don't think this ever gets used by current displays)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.intGet the number of classes for the current classifier.Get the parent data block.Get the segmenter process.Get the settings pane.longGets a reference to a small panel to be displayed along the left hand edge of the main tab panel.booleanCheck whether group detections are being used.booleanrestoreSettings(PamControlledUnitSettings pamControlledUnitSettings) voidsetGroupDetections(boolean groupDetections) Set whether to use group detections.voidsetParams(RawDLParams newParams) voidshowSettingsDialog(Frame parentFrame) Show settings dialog.voidupdate(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, getUnitTaskManager, getUnitTaskManager, getUnitType, getVerboseLevel, gotoTab, isInMainConfiguration, isNetRx, isViewer, notifyModelChanged, pamClose, pamHasStopped, pamToStart, playViewerSound, removePamProcess, removeUnit, rename, saveViewerData, setFrameNumber, setModuleStatusManager, setPamConfiguration, setPamController, setPamModuleInfo, setPamView, setSidePanel, setTabPanel, setToolbarComponent, setUnitTaskManager, setupControlledUnit, stopViewerSound, tellModule, terminalPrint, terminalPrintln, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface PamController.PamSettings
getUnitTypeMethods 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:
getSettingsReferencein interfacePamSettings- Returns:
- The serialisable object that will be stored
-
getSettingsVersion
public long getSettingsVersion()- Specified by:
getSettingsVersionin interfacePamSettings- Returns:
- An integer version number for the settings
-
restoreSettings
- Specified by:
restoreSettingsin interfacePamSettings- Parameters:
pamControlledUnitSettings-- 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:PamControlledUnitGets 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:
getSidePanelin classPamControlledUnit- Returns:
- a pamSidePanel object.
- See Also:
-
createDetectionMenu
Description copied from class:PamControlledUnitCreate a JMenu object containing MenuItems associated with PamProcesses- Overrides:
createDetectionMenuin 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:
getGUIin 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.
-
isGroupDetections
public boolean isGroupDetections()Check whether group detections are being used. If true then detections are saved to a group and all detections within a segment are then passed to the deep learning classifier. -
setGroupDetections
public void setGroupDetections(boolean groupDetections) Set whether to use group detections. If true then detections are saved to a group and all detections within a segment are then passed to the deep learning classifier.- Parameters:
groupDetections- - true to use group detections.
-
getClipDataBlock
- Specified by:
getClipDataBlockin interfaceClipDisplayParent- Returns:
- the data block who's clips are to be displayed
-
getDisplayName
Description copied from interface:ClipDisplayParentA name (though I don't think this ever gets used by current displays)- Specified by:
getDisplayNamein interfaceClipDisplayParent- Returns:
- display name
-
getClipDecorations
Description copied from interface:ClipDisplayParentAdd additional functionality and controls to a clip display unit- Specified by:
getClipDecorationsin interfaceClipDisplayParent- Parameters:
clipDisplayUnit- display unit to decorate.
-
displaySettingChange
public void displaySettingChange()- Specified by:
displaySettingChangein interfaceClipDisplayParent
-