public class Dl4jCNNExplorer
extends java.lang.Object
implements java.io.Serializable, weka.core.OptionHandler, weka.core.CommandlineRunnable
Constructor and Description |
---|
Dl4jCNNExplorer() |
Modifier and Type | Method and Description |
---|---|
void |
checkArgs()
Check the arguments for the explorer.
|
void |
finishProgress()
Close up all progress managers when we finish processing.
|
void |
generateAndSaveOutputMap()
Generate the output heatmap, and save to file.
|
java.awt.image.BufferedImage |
generateOutputMap()
Generate and return the heatmap.
|
TopNPredictions |
getCurrentPredictions() |
CustomModelSetup |
getCustomModelSetup() |
boolean |
getGenerateSaliencyMap() |
java.lang.String |
getModelName()
Get the name of the loaded model
|
ModelOutputDecoder |
getModelOutputDecoder() |
java.lang.String[] |
getOptions()
Gets the current settings of the Classifier.
|
AbstractCNNSaliencyMapWrapper |
getSaliencyMapWrapper() |
boolean |
getUseCustomModel() |
AbstractZooModel |
getZooModelType() |
void |
init()
Initialize the ComputationGraph.
|
java.util.Enumeration<weka.core.Option> |
listOptions()
Returns an enumeration describing the available options.
|
void |
postExecution()
Perform any teardown stuff that might need to happen after execution.
|
void |
preExecution()
Perform any setup stuff that might need to happen before execution.
|
void |
processImage(java.io.File imageFile)
Performs prediction and (optionally) computes a saliency map.
|
void |
run(java.lang.Object toRun,
java.lang.String[] options)
Execute the supplied object.
|
void |
setCustomModelSetup(CustomModelSetup customModelSetup) |
void |
setGenerateSaliencyMap(boolean generateSaliencyMap) |
void |
setModelOutputDecoder(ModelOutputDecoder modelOutputDecoder) |
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
void |
setSaliencyMapWrapper(AbstractCNNSaliencyMapWrapper saliencyMapWrapper) |
void |
setUseCustomModel(boolean useCustomModel) |
void |
setZooModelType(AbstractZooModel zooModelType) |
public void init() throws java.lang.Exception
java.lang.Exception
- Exceptions from loading the ComputationGraphpublic void checkArgs() throws weka.core.WekaException
weka.core.WekaException
- If the user hasn't selected a model filepublic void processImage(java.io.File imageFile) throws java.lang.Exception
imageFile
- Image to compute.java.lang.Exception
- Exception during prediction.public java.awt.image.BufferedImage generateOutputMap()
public void generateAndSaveOutputMap()
public java.lang.String getModelName()
public TopNPredictions getCurrentPredictions()
public void finishProgress()
@OptionMetadata(commandLineParamIsFlag=true, commandLineParamName="useCustomModel", commandLineParamSynopsis="-useCustomModel", displayName="Use custom-trained model file", description="Use the a custom-trained Dl4jMlpClassifier serialized model file, instead of the zoo model.", displayOrder=0) public boolean getUseCustomModel()
public void setUseCustomModel(boolean useCustomModel)
@OptionMetadata(displayName="Custom model setup", description="Options to set if using a custom-trained model", commandLineParamName="custom-model", commandLineParamSynopsis="-customModel <options>", displayOrder=1) public CustomModelSetup getCustomModelSetup()
public void setCustomModelSetup(CustomModelSetup customModelSetup)
@OptionMetadata(displayName="Pretrained zoo model", description="Type of pretrained model to use for prediction (instead of trained Dl4jMlpClassifier)", commandLineParamName="zooModel", commandLineParamSynopsis="-zooModel <options>", displayOrder=2) public AbstractZooModel getZooModelType()
public void setZooModelType(AbstractZooModel zooModelType)
@OptionMetadata(displayName="Model output decoder", description="Handles decoding of the model predictions", commandLineParamName="decoder", commandLineParamSynopsis="-decoder <options>", displayOrder=3) public ModelOutputDecoder getModelOutputDecoder()
public void setModelOutputDecoder(ModelOutputDecoder modelOutputDecoder)
@OptionMetadata(displayName="Generate saliency map", description="Should the model explorer generate a ScoreCAM saliency map?", commandLineParamName="generate-map", commandLineParamSynopsis="-generate-map", commandLineParamIsFlag=true, displayOrder=4) public boolean getGenerateSaliencyMap()
public void setGenerateSaliencyMap(boolean generateSaliencyMap)
@OptionMetadata(displayName="Saliency map generator", description="Saliency map options", commandLineParamName="saliency-map", commandLineParamSynopsis="-saliency-map <options>", displayOrder=5) public AbstractCNNSaliencyMapWrapper getSaliencyMapWrapper()
public void setSaliencyMapWrapper(AbstractCNNSaliencyMapWrapper saliencyMapWrapper)
public void preExecution() throws java.lang.Exception
preExecution
in interface weka.core.CommandlineRunnable
java.lang.Exception
- if a problem occurs during setuppublic void run(java.lang.Object toRun, java.lang.String[] options) throws java.lang.Exception
run
in interface weka.core.CommandlineRunnable
toRun
- the object to executeoptions
- any options to pass to the objectjava.lang.Exception
- if a problem occurs.public void postExecution() throws java.lang.Exception
postExecution
in interface weka.core.CommandlineRunnable
java.lang.Exception
- if a problem occurs during teardownpublic java.util.Enumeration<weka.core.Option> listOptions()
listOptions
in interface weka.core.OptionHandler
public java.lang.String[] getOptions()
getOptions
in interface weka.core.OptionHandler
public void setOptions(java.lang.String[] options) throws java.lang.Exception
setOptions
in interface weka.core.OptionHandler
options
- the list of options as an array of stringsjava.lang.Exception
- if an option is not supported