def call_disk_worker()

in community-artifacts/Deep-learning/Utilities/madlib_image_loader.py [0:0]


    def call_disk_worker(self, label):
        dir_name = os.path.join(self.root_dir,label)

        filenames = os.listdir(dir_name)
        data = []
        first_image = Image.open(os.path.join(self.root_dir, label, filenames[0]))
        for index, filename in enumerate(filenames):
            image = Image.open(os.path.join(self.root_dir, label, filename))
            x = np.array(image)
            if x.shape != np.array(first_image).shape:
                raise Exception("Images {0} and {1} in label {2} have different "
                                "shapes {0}:{3} {1}:{4}.  Make sure that all the "
                                "images are of the same shape."\
                    .format(filenames[0], filename, label,
                            first_image.shape, x.shape))

            data.append((x, label, filename))
            if (index % self.ROWS_PER_FILE) == (self.ROWS_PER_FILE - 1):
                _call_np_worker(data)
                data = []

        if len(data) > 0:
            _call_np_worker(data)