Package org.deeplearning4j.zoo.util
Class BaseLabels
- java.lang.Object
-
- org.deeplearning4j.zoo.util.BaseLabels
-
- All Implemented Interfaces:
Labels
- Direct Known Subclasses:
COCOLabels,DarknetLabels,ImageNetLabels,VOCLabels
public abstract class BaseLabels extends Object implements Labels
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseLabels()OverridegetLabels()when using this constructor.protectedBaseLabels(String textResource)No need to override anything with this constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description List<List<ClassPrediction>>decodePredictions(INDArray predictions, int n)Given predictions from the trained model this method will return a list of the top n matches and the respective probabilities.StringgetLabel(int n)Returns the description of the nth class from the classes of a dataset.protected ArrayList<String>getLabels()Override to return labels when not callingBaseLabels(String).protected ArrayList<String>getLabels(String textResource)Returns labels based on the text file resource.protected FilegetResourceFile()Download the resource at getURL() to the local resource directory, and return the local copy as a Fileprotected abstract URLgetURL()protected abstract StringresourceMD5()protected abstract StringresourceName()
-
-
-
Constructor Detail
-
BaseLabels
protected BaseLabels() throws IOExceptionOverridegetLabels()when using this constructor.- Throws:
IOException
-
BaseLabels
protected BaseLabels(String textResource) throws IOException
No need to override anything with this constructor.- Parameters:
textResource- name of a resource containing labels as a list in a text file.- Throws:
IOException
-
-
Method Detail
-
getLabels
protected ArrayList<String> getLabels() throws IOException
Override to return labels when not callingBaseLabels(String).- Throws:
IOException
-
getLabels
protected ArrayList<String> getLabels(String textResource) throws IOException
Returns labels based on the text file resource.- Throws:
IOException
-
getLabel
public String getLabel(int n)
Description copied from interface:LabelsReturns the description of the nth class from the classes of a dataset.
-
decodePredictions
public List<List<ClassPrediction>> decodePredictions(INDArray predictions, int n)
Description copied from interface:LabelsGiven predictions from the trained model this method will return a list of the top n matches and the respective probabilities.- Specified by:
decodePredictionsin interfaceLabels- Parameters:
predictions- raw- Returns:
- decoded predictions
-
getURL
protected abstract URL getURL()
- Returns:
- URL of the resource to download
-
resourceName
protected abstract String resourceName()
- Returns:
- Name of the resource (used for inferring local storage parent directory)
-
resourceMD5
protected abstract String resourceMD5()
- Returns:
- MD5 of the resource at getURL()
-
getResourceFile
protected File getResourceFile()
Download the resource at getURL() to the local resource directory, and return the local copy as a File- Returns:
- File of the local resource
-
-