N_classes = 1 if len(CLASSES) = 1 else (len(CLASSES) + 1)Īctivation = 'sigmoid' if n_classes = 1 else 'softmax' Preprocess_input = sm.get_preprocessing(BACKBONE) Self.indexes = np.random.permutation(self.indexes) Return len(self.indexes) // self.batch_size Sample = self.preprocessing(image=image, mask=mask)ĭef _init_(self, dataset, batch_size=1, shuffle=False):īatch = Sample = gmentation(image=image, mask=mask) Mask = np.concatenate((mask, background), axis=-1) Mask = np.stack(masks, axis=-1).astype('float')īackground = 1 - mask.sum(axis=-1, keepdims=True) Image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) Y_valid_dir = os.path.join(DATA_DIR, 'valmask') X_valid_dir = os.path.join(DATA_DIR, 'val') Y_train_dir = os.path.join(DATA_DIR, 'mask') X_train_dir = os.path.join(DATA_DIR, 'image') With ZipFile('/content/drive/MyDrive/face_segmentation_data.zip', 'r') as zipObj:įrom _backend import set_session
KERAS DATA AUGMENTATION FOR 3D INSTALL
!pip install -U -pre segmentation-models -user !pip install -U albumentations>=0.3.0 -user !pip install 'h5py=2.10.0' -force-reinstall