Skip to content
Advertisement

is this txt file actually an image?

I found this GitHub rep about image classification (Male and female images) using an artificial neural network, the training data are 2 directories “./male”, and “./female”, each one contains a list of txt files.

these text files contain rows of numbers, each row of 16 numbers. a preview

37 40 48 49 49 45 41 34 34 34 33 34 33 33 33 33
32 31 31 31 30 30 29 29 28 27 28 27 27 26 26 26
25 25 24 24 24 23 23 22 22 21 21 20 20 19 19 19
18 19 20 21 25 25 24 22 16 17 15 22 21 20 21 20
20 20 19 19 19 16 20 21 23 23 23 23 23 23 23 24
24 24 25 24 24 25 26 25 25 26 26 25 26 26 26 26
27 27 27 28 28 29 29 29 29 30 29 29 29 29 29 29
29 30 29 29 30 30 30 30 30 30 29 29 29 29 28 29
...

I don’t understand! ARE THESE SUPPOSED TO BE IMAGES (matrices of pixels values)?

the rep link: https://github.com/Kurispy/neuralnet

Advertisement

Answer

By investigating the source code of Main.java we see that files are intended to be painted https://github.com/Kurispy/neuralnet/blob/master/Main.java#L90

public static void painter(FileInputStream fin) {
double[] store = new double[120 * 128];
    byte[] buffer = new byte[(15360 + 1) * 8];
    ByteBuffer b = ByteBuffer.wrap(buffer);
    DoubleBuffer db = b.asDoubleBuffer();
    
    try {
        while(fin.available() > 0) {
            fin.read(buffer, 0, (15360 + 1) * 8);
        
            
            db.get();
            db.get(store);
            db.rewind();
            paint(store);
        }
    }
    catch (java.io.IOException e) {
        System.err.println(e.getMessage());
    }
    
    
}

and we see that each file is interpreted as 120 x 128 grayscale image, by loading first file and trying to plot it like this we see it is a picture of a face.enter image description here

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement