Search code examples
pythonnumpyglob

glob(os.path.join()) to work with the .npy data


I am trying to augment DC-GANS code so that it works with my data. The original code has its data as JPEG, however I would really strongly prefer to have my data in .npy.

The problem is line 76: self.data = glob(os.path.join("./data", self.dataset_name, self.input_fname_pattern)) won't work with numpy data (it comes back blank, i.e. []).

Hence I am wondering what's a good replacement for glob(os.path.join()) for numpy files? Or are there any parameters that would make glob compatible with the numpy data?


Solution

  • In DCGAN.__init__, change input_fname_pattern='*.jpg' to input_fname_pattern='*.npy':

    class DCGAN(object):
      def __init__(self, ...
                   input_fname_pattern='*.npy'...):
    

    This will change the default value of input_fname_pattern to '*.npy'.

    Alternatively, when you instantiate DCGAN, you could pass input_fname_pattern='*.npy' to it:

    dcgan = DCGAN(sess, input_fname_pattern='*.npy')
    

    If you do one of those two things, then glob(os.path.join("./data", self.dataset_name, self.input_fname_pattern)) will return any .npy file names in the self.dataset_name subdirectory of ./data.