glob(os.path.join())使用.npy数据

时间:2022-09-01 22:59:57

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.

我正在尝试增强DC-GANS代码,以便它可以处理我的数据。原始代码的数据为JPEG,但我真的非常希望将数据放在.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. []).

问题是第76行:self.data = glob(os.path.join(“./ data”,self.dataset_name,self.input_fname_pattern))不能使用numpy数据(它返回空白,即[]) 。

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?

因此,我想知道什么是numpy文件的glob(os.path.join())的一个很好的替代品?或者是否有任何参数可以使glob与numpy数据兼容?

1 个解决方案

#1


1  

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

在DCGAN .__ init__中,将input_fname_pattern ='*。jpg'更改为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'.

这会将input_fname_pattern的默认值更改为'* .npy'。

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

或者,当您实例化DCGAN时,您可以将input_fname_pattern ='*。npy'传递给它:

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.

如果你执行这两件事之一,那么glob(os.path.join(“./ data”,self.dataset_name,self.input_fname_pattern))将在./data的self.dataset_name子目录中返回任何.npy文件名。 。

#1


1  

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

在DCGAN .__ init__中,将input_fname_pattern ='*。jpg'更改为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'.

这会将input_fname_pattern的默认值更改为'* .npy'。

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

或者,当您实例化DCGAN时,您可以将input_fname_pattern ='*。npy'传递给它:

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.

如果你执行这两件事之一,那么glob(os.path.join(“./ data”,self.dataset_name,self.input_fname_pattern))将在./data的self.dataset_name子目录中返回任何.npy文件名。 。