Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

2D segmentation Error #52

Closed
yenhochen opened this issue Feb 21, 2018 · 2 comments
Closed

2D segmentation Error #52

yenhochen opened this issue Feb 21, 2018 · 2 comments

Comments

@yenhochen
Copy link

yenhochen commented Feb 21, 2018

I'm currently trying to segment 2D RGB (256x256x3) images. I've converted my images to the .nii format in order to make it compatible with NiftyNet. As a test, I tried to run a training segmentation session with the Vnet application. However, I keep getting the following error no matter how I tweak the configuration file.

ValueError: Dimension 1 in both shapes must be equal, but are 2 and 1 for 'worker_0/VNet/residual_concat/concat' (op: 'ConcatV2') with input shapes: [20,2,2,256], [20,1,1,128], [] and with computed input tensors: input[2] = <-1>.

Below is my configuration file:

[input]
path_to_search = data/DSB_stage1_train/data
filename_contains = train, _data, nii
spatial_window_size = 8, 8, 1

[label]
path_to_search = data/DSB_stage1_train/labels3d
filename_contains = train, _labels, nii
spatial_window_size = 8, 8, 1

############################## system configuration sections
[SYSTEM]
cuda_devices = 2
num_threads = 2
num_gpus = 1
model_dir = ./nntest

[NETWORK]
name = vnet
activation_function = prelu
batch_size = 20
volume_padding_size=0

[TRAINING]
lr = 0.0002
loss_type = Dice
starting_iter = 0
max_iter = 100

############################ custom configuration sections
[SEGMENTATION]
image = input
label = label
num_classes = 2

I am currently using Red Hat Linux with Tensorflow 1.3 and Python 2.7. I always cd to my NiftyNet directory before I execute the following command: python net_segment.py train -c DSBtrain.ini

What am I doing wrong?

@wyli
Copy link
Member

wyli commented Mar 6, 2018

Hi @yenhochen it seems thespatial_window_size is too small in this case.

@imaluengo
Copy link
Contributor

imaluengo commented Mar 7, 2018

@mariamhrr @wyli Since the merge of image-loader NiftyNet now fully supports 2D images without having to convert them to NiftyFormat. There is no need to fake 3-dimensional spatial_window_size either (although it is perfectly ok if you do).

NiftyNet currently supports loading images from OpenCV, Scikit-Image and PIL/Pillow, assuming that you have the corresponding libraries installed. You can specify a loader in the config file, or it will automatically try to find one that can handle yout images.

Pretty much every 2D image format is supported (as long as it can be loaded by one of those libraries): .jpg, .png, .bpm, .tif ...

For more information check image_loader.py.

Example configuration file:

[images]
path_to_search = ~/data/test_image_segmentation/
filename_contains = bmp
spatial_window_size = (224, 224)
interp_order = 1
loader = opencv

[masks]
path_to_search = ~/data/test_image_segmentation/
filename_contains = _mask
spatial_window_size = (224, 224)
interp_order = 0
loader = skimage

@wyli wyli closed this as completed Mar 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants