0

I'm training a simple convolution neural network using pylearn2. I have my RGB image data stored in a npy file. Is there anyway to convert that data directly to grayscale data directly from the npy file?

SameeraR
  • 415
  • 1
  • 6
  • 19

1 Answers1

1

If this is a standalone file then load the file using numpy.load then convert the content using something like this:

def rgb2gray(rgb):
    return np.dot(rgb[...,:3], [0.299, 0.587, 0.144])

If the file is part of a pylearn2 dataset (resulted from use_design_loc()), then load the dataset

from pylearn2.utils import serial
serial.load("file.pkl")

and apply rgb2gray() function to X member (I assume a DenseDesignMatrix).

Suraj
  • 2,253
  • 3
  • 17
  • 48
Nicu Tofan
  • 1,052
  • 14
  • 34