Nuclei detection

Nuclei detection
0

I am currently working on topic of Nuclei detection in python (Keras) and the dataset that I used is from “https://warwick.ac.uk/fac/sci/dcs/research/tia/data/crchistolabelednucleihe/”. The data set consists of 100 (H&E) stained histopathology images and the dataset just provides the coordinates of cell centroids. So I created binary image by plotting these coordinates and used those images as a training labels and tried to train my model but this doesn’t give any result.
Following is the code that how did I load my training images and training labels.

# Set seed values
seed = 42
random.seed = seed
np.random.seed(seed=seed)

# Get training data
def get_X_data(path, output_shape=(None, None)):
    '''
    Loads images from path into a numpy array
    '''
    img_paths = ['/content/drive/My Drive/Detection/Train/{1}'.format(path, id) for id in os.listdir(path)]

    X_data = np.array([skimage.transform.resize(skimage.io.imread(path)[:,:,:3], output_shape=output_shape, mode='constant', 
                    preserve_range=True) for path in img_paths], dtype=np.uint8)  
    
    return X_data

X_train = get_X_data(train_path, output_shape=(256,256))
print(X_train.shape, X_train.dtype)
### Labels######
def get_Y_data(path, output_shape=(None, None)):
    '''
    Loads and concatenates images into a numpy array
    '''
    img_paths = ['/content/drive/My Drive/mask/{1}'.format(path, id) for id in os.listdir(path)]

    Y_data = np.array([skimage.transform.resize(skimage.io.imread(path), output_shape=output_shape, mode='constant', 
                    preserve_range=True) for path in img_paths], dtype=np.uint8)  
    Y_data = np.array(Y_data, dtype=np.bool) 
    return Y_data
         
Y_train = get_Y_data(train_path, output_shape=(256,256,1))
print(Y_train.shape, Y_train.dtype)    
def get_train_test_augmented(X_data=X_train, Y_data=Y_train, validation_split=0.25, batch_size=16, seed=seed):
    X_train, X_test, Y_train, Y_test = train_test_split(X_data,
                                                        Y_data,
                                                        train_size=1-validation_split,
                                                        test_size=validation_split,
                                                        random_state=seed)
    
    # Image data generator distortion options
    data_gen_args = dict(rotation_range=45.,
                         width_shift_range=0.1,
                         height_shift_range=0.1,
                         shear_range=0.2,
                         zoom_range=0.2,
                         horizontal_flip=True,
                         vertical_flip=True,
                         fill_mode='reflect')  


    # Train data
    X_datagen = ImageDataGenerator(**data_gen_args)
    Y_datagen = ImageDataGenerator(**data_gen_args)
    X_datagen.fit(X_train, augment=True, seed=seed)
    Y_datagen.fit(Y_train, augment=True, seed=seed)
    X_train_augmented = X_datagen.flow(X_train, batch_size=batch_size, shuffle=True, seed=seed)
    Y_train_augmented = Y_datagen.flow(Y_train, batch_size=batch_size, shuffle=True, seed=seed)
     
    
    # Validation data, no data augmentation
    X_datagen_val = ImageDataGenerator()
    Y_datagen_val = ImageDataGenerator()
    X_datagen_val.fit(X_test, augment=True, seed=seed)
    Y_datagen_val.fit(Y_test, augment=True, seed=seed)
    X_test_augmented = X_datagen_val.flow(X_test, batch_size=batch_size, shuffle=True, seed=seed)
    Y_test_augmented = Y_datagen_val.flow(Y_test, batch_size=batch_size, shuffle=True, seed=seed)
    
    
    # combine generators into one which yields image and masks
    train_generator = zip(X_train_augmented, Y_train_augmented)
    test_generator = zip(X_test_augmented, Y_test_augmented)
    
    return train_generator, test_generator