Esempio n. 1
0
    def LoadFromNpys(self, dir, classes):

        self.imgDataWrappers = np.empty(0,
                                        dtype=ImgDataWrapperMultiTypesMemory)

        npysImgs = CommonUtil.GetFileFromThisRootDir(
            os.path.join(dir, "arrImgs"), ".npy")
        npysMasks = CommonUtil.GetFileFromThisRootDir(
            os.path.join(dir, "masks"), ".npy")
        if len(npysImgs) != len(npysMasks):
            print(
                "WARNING: Count of img inputs is different from count of mask inputs."
            )
        for i in range(len(npysImgs)):
            # print("Loading",i,":")
            # print("  " + npysImgs[i])
            # print("  " + npysMasks[i])
            imgs = np.load(npysImgs[i])
            masks = np.load(npysMasks[i])
            # print(imgs.shape)
            # print(masks.shape)
            if imgs is None:
                raise Exception("Imgs is none. No img has been read.")
            if masks is None:
                raise Exception("Masks is none. No mask has been read.")

            self.imgDataWrappers = np.insert(self.imgDataWrappers, len(self.imgDataWrappers), \
                                             ImgDataWrapperMultiTypesMemory(imgs, masks, classes, imgDataFmt=imgs.dtype,
                                                                  maskDataFmt=masks.dtype, isMaskOneHot=True), \
                                             axis=0)
Esempio n. 2
0
 def __LoadFromNPYs(self, dirWrapper):
     dirData = os.path.join(dirWrapper, "data")
     dirMasks = os.path.join(dirWrapper, "masks")
     self.pathsImg = CommonUtil.GetFileFromThisRootDir(dirData, ".npy")
     self.pathsMasks = CommonUtil.GetFileFromThisRootDir(dirMasks, ".npy")