nabsabraham / focal-tversky-unet

This repo contains the code for our paper "A novel focal Tversky loss function and improved Attention U-Net for lesion segmentation" accepted at IEEE ISBI 2019.
357 stars 72 forks source link

gt_train issue #15

Closed AmericaBG closed 4 years ago

AmericaBG commented 4 years ago

Hi! First of all, than you very much for sharing your code. It's a great work!

I'm having troubles when I create gt_train.

The error is: ValueError: could not broadcast input array from shape (7009,32,32,1) into shape (7009)

I use 256x256x1 images and augmented data with Imagedatagenerator.

My code is as follows: (Y_train is ground truth) gt1 = Y_train[:,::8,::8,:] gt2 = Y_train[:,::4,::4,:] gt3 = Y_train[:,::2,::2,:] gt4 = Y_train gt_train = [gt1,gt2,gt3,gt4]

train_datagen = ImageDataGenerator(shear_range = 0.2, zoom_range = 0.2, horizontal_flip = True) mask_datagen = ImageDataGenerator(shear_range = 0.2, zoom_range = 0.2, horizontal_flip = True) train_datagen.fit(X_train) mask_datagen.fit(gt_train)

# train_set = train_datagen.flow(X_train,seed=seed, batch_size=config.BATCH_SIZE, shuffle=True) mask_set = mask_datagen.flow(gt_train,seed=seed, batch_size=config.BATCH_SIZE, shuffle=True)

train_generator = zip(train_set, mask_set)

results=model.fit_generator(train_generator, steps_per_epoch...)

Thank you very much in advance! Best wishes.

nabsabraham commented 4 years ago

Hi! Sorry didn't get to this in time - did you figure out your issue? As a check, print your Y_train shape before the subsampling begins - I believe your problem is that the input spatial resolution 32x32 is too small to be subsampled by a factor of 8