Package org.datavec.image.recordreader
Class BaseImageRecordReader
- java.lang.Object
-
- org.datavec.api.records.reader.BaseRecordReader
-
- org.datavec.image.recordreader.BaseImageRecordReader
-
- All Implemented Interfaces:
Closeable,Serializable,AutoCloseable,Configurable,RecordReader
- Direct Known Subclasses:
ImageRecordReader,ObjectDetectionRecordReader
public abstract class BaseImageRecordReader extends BaseRecordReader
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanappendLabelprotected longchannelsstatic StringCHANNELSprotected Configurationconfstatic StringCROP_IMAGEprotected booleancropImageprotected FilecurrentFileprotected Map<String,String>fileNameMapprotected booleanfinishedInputStreamSplitprotected longheightstatic StringHEIGHTprotected booleanhitImagestatic StringIMAGE_LOADERprotected BaseImageLoaderimageLoaderprotected ImageTransformimageTransformprotected InputSplitinputSplitprotected Iterator<File>iterprotected PathLabelGeneratorlabelGeneratorprotected PathMultiLabelGeneratorlabelMultiGeneratorprotected List<String>labelsprotected booleanlogLabelCountOnInitprotected booleannchw_channels_firstprotected Stringpatternprotected intpatternPositionprotected List<Writable>recordprotected longwidthstatic StringWIDTHprotected booleanwriteLabel-
Fields inherited from class org.datavec.api.records.reader.BaseRecordReader
listeners, streamCreatorFn
-
Fields inherited from interface org.datavec.api.records.reader.RecordReader
APPEND_LABEL, LABELS, NAME_SPACE
-
-
Constructor Summary
Constructors Modifier Constructor Description BaseImageRecordReader()protectedBaseImageRecordReader(long height, long width, long channels, boolean nchw_channels_first, PathLabelGenerator labelGenerator, PathMultiLabelGenerator labelMultiGenerator, ImageTransform imageTransform)BaseImageRecordReader(long height, long width, long channels, PathLabelGenerator labelGenerator)protectedBaseImageRecordReader(long height, long width, long channels, PathLabelGenerator labelGenerator, PathMultiLabelGenerator labelMultiGenerator, ImageTransform imageTransform)BaseImageRecordReader(long height, long width, long channels, PathLabelGenerator labelGenerator, ImageTransform imageTransform)BaseImageRecordReader(long height, long width, long channels, PathMultiLabelGenerator labelGenerator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaccumulateLabel(String path)Accumulate the label from the pathbooleanbatchesSupported()voidclose()protected booleancontainsFormat(String format)ConfigurationgetConf()FilegetCurrentFile()Returns the file loaded last bynext().StringgetLabel(String path)Get the label from the given pathList<String>getLabels()booleanhasNext()voidinitialize(Configuration conf, InputSplit split)voidinitialize(Configuration conf, InputSplit split, ImageTransform imageTransform)Called once at initialization.voidinitialize(InputSplit split)voidinitialize(InputSplit split, ImageTransform imageTransform)Called once at initialization.List<Record>loadFromMetaData(List<RecordMetaData> recordMetaDatas)RecordloadFromMetaData(RecordMetaData recordMetaData)List<Writable>next()List<List<Writable>>next(int num)RecordnextRecord()intnumLabels()ReturnsgetLabels().size().List<Writable>record(URI uri, DataInputStream dataInputStream)voidreset()booleanresetSupported()voidsetConf(Configuration conf)voidsetCurrentFile(File currentFile)Sets manually the file returned bygetCurrentFile().voidsetLabels(List<String> labels)-
Methods inherited from class org.datavec.api.records.reader.BaseRecordReader
getListeners, invokeListeners, setListeners, setListeners
-
-
-
-
Field Detail
-
finishedInputStreamSplit
protected boolean finishedInputStreamSplit
-
conf
protected Configuration conf
-
currentFile
protected File currentFile
-
labelGenerator
protected PathLabelGenerator labelGenerator
-
labelMultiGenerator
protected PathMultiLabelGenerator labelMultiGenerator
-
appendLabel
protected boolean appendLabel
-
writeLabel
protected boolean writeLabel
-
hitImage
protected boolean hitImage
-
height
protected long height
-
width
protected long width
-
channels
protected long channels
-
cropImage
protected boolean cropImage
-
imageTransform
protected ImageTransform imageTransform
-
imageLoader
protected BaseImageLoader imageLoader
-
inputSplit
protected InputSplit inputSplit
-
pattern
protected String pattern
-
patternPosition
protected int patternPosition
-
logLabelCountOnInit
protected boolean logLabelCountOnInit
-
nchw_channels_first
protected boolean nchw_channels_first
-
HEIGHT
public static final String HEIGHT
-
WIDTH
public static final String WIDTH
-
CHANNELS
public static final String CHANNELS
-
CROP_IMAGE
public static final String CROP_IMAGE
-
IMAGE_LOADER
public static final String IMAGE_LOADER
-
-
Constructor Detail
-
BaseImageRecordReader
public BaseImageRecordReader()
-
BaseImageRecordReader
public BaseImageRecordReader(long height, long width, long channels, PathLabelGenerator labelGenerator)
-
BaseImageRecordReader
public BaseImageRecordReader(long height, long width, long channels, PathMultiLabelGenerator labelGenerator)
-
BaseImageRecordReader
public BaseImageRecordReader(long height, long width, long channels, PathLabelGenerator labelGenerator, ImageTransform imageTransform)
-
BaseImageRecordReader
protected BaseImageRecordReader(long height, long width, long channels, PathLabelGenerator labelGenerator, PathMultiLabelGenerator labelMultiGenerator, ImageTransform imageTransform)
-
BaseImageRecordReader
protected BaseImageRecordReader(long height, long width, long channels, boolean nchw_channels_first, PathLabelGenerator labelGenerator, PathMultiLabelGenerator labelMultiGenerator, ImageTransform imageTransform)
-
-
Method Detail
-
containsFormat
protected boolean containsFormat(String format)
-
initialize
public void initialize(InputSplit split) throws IOException
- Specified by:
initializein interfaceRecordReader- Overrides:
initializein classBaseRecordReader- Throws:
IOException
-
initialize
public void initialize(Configuration conf, InputSplit split) throws IOException, InterruptedException
- Throws:
IOExceptionInterruptedException
-
initialize
public void initialize(InputSplit split, ImageTransform imageTransform) throws IOException
Called once at initialization.- Parameters:
split- the split that defines the range of records to readimageTransform- the image transform to use to transform images while loading them- Throws:
IOException
-
initialize
public void initialize(Configuration conf, InputSplit split, ImageTransform imageTransform) throws IOException, InterruptedException
Called once at initialization.- Parameters:
conf- a configuration for initializationsplit- the split that defines the range of records to readimageTransform- the image transform to use to transform images while loading them- Throws:
IOExceptionInterruptedException
-
hasNext
public boolean hasNext()
-
batchesSupported
public boolean batchesSupported()
- Specified by:
batchesSupportedin interfaceRecordReader- Overrides:
batchesSupportedin classBaseRecordReader
-
next
public List<List<Writable>> next(int num)
- Specified by:
nextin interfaceRecordReader- Overrides:
nextin classBaseRecordReader
-
close
public void close() throws IOException- Throws:
IOException
-
setConf
public void setConf(Configuration conf)
-
getConf
public Configuration getConf()
-
getLabel
public String getLabel(String path)
Get the label from the given path- Parameters:
path- the path to get the label from- Returns:
- the label for the given path
-
accumulateLabel
protected void accumulateLabel(String path)
Accumulate the label from the path- Parameters:
path- the path to get the label from
-
setCurrentFile
public void setCurrentFile(File currentFile)
Sets manually the file returned bygetCurrentFile().
-
reset
public void reset()
-
resetSupported
public boolean resetSupported()
-
numLabels
public int numLabels()
ReturnsgetLabels().size().
-
record
public List<Writable> record(URI uri, DataInputStream dataInputStream) throws IOException
- Throws:
IOException
-
nextRecord
public Record nextRecord()
-
loadFromMetaData
public Record loadFromMetaData(RecordMetaData recordMetaData) throws IOException
- Throws:
IOException
-
loadFromMetaData
public List<Record> loadFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException
- Throws:
IOException
-
-