Image Inputs for ImageRecordReader

Hey everyone! I’m a student working on a final project for my undergrad machine learning course, and I’m trying to use DL4J for CNN image classification on this dataset:

I’ve gotten the network to run well on the CIFAR-10 dataset, but I’m having a little trouble switching over to this new bird species one since there’s no built-in DataSetIterator like there was for the CIFAR-10. How do I have to format the image file directory to work with the ImageRecordReader? The data-set is saved in the following format currently:

where there are 180 species of birds in each train/test/validation folders.

Thanks for your help!

Take a look at this section:

And then take a look at this part of the mnist classifier example:

The first link should tell you how it is supposed to be used generally, and the second link shows you how it is used to load MNIST train and test data that is effectively organized exactly like your bird species data.

The only real difference is that you’ve got 3 channels instead of 1 and that your width and height values are different.

This worked perfectly, thank you!

EDIT: It seems that the ImageRecordReader is going into an in-determinant state:

Exception in thread “main” java.lang.IllegalStateException: Indeterminant state: record must not be null, or a file iterator must exist
at org.datavec.image.recordreader.BaseImageRecordReader.hasNext(
at org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator.hasNext(
at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.doEvaluationHelper(
at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.doEvaluation(
at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.evaluate(
at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.evaluate(
at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.evaluate(
at org.example.App.(
at org.example.App.main(

Is there anything I can do to fix this? It was able to run for about 1500 iterations as per the UIserver.

Please share the code you are using define your test data set iterator.

According to the stack trace it happens when you are running .evaluate, and that uses your iterator for test data.

Configuring the testing data:

    testData = new File("D:\\cam29\\Downloads\\100-bird-species\\180\\test");
    FileSplit testSplit = new FileSplit(testData, NativeImageLoader.ALLOWED_FORMATS, new Random());
    ImageRecordReader rrTest = new ImageRecordReader(224,224,3, labelMaker);
    DataSetIterator testIterator = new RecordReaderDataSetIterator(rrTest, 64, 1, 180);

And calling for the evaluation after, numEpochs):

Evaluation evaluation = network.evaluate(testIterator);

That is your problem. You should have used rrTest here.

Thank you, can’t believe I missed that!