SegCaps icon indicating copy to clipboard operation
SegCaps copied to clipboard

Training image and mask error

Open tanchaozhen opened this issue 4 years ago • 4 comments

Thank you for your implementation of SegCaps. I train on my dataset ,got a problem"Unable to load img or masks for 00001,too many indices for array,Skipping file". When loading MSCOO dataset with 10 images, it works. My image are 2D uint8 greyscale of (512,512), masks are the same 2D uint8 greyscale of (512,512). I checked the Issues, someone said masks should be (512,512,1), Does my images and masks fit the input format?If not, what should I do for it? Any advice would be appreciated.

tanchaozhen avatar Nov 26 '19 14:11 tanchaozhen

@Cheng-Lin-Li help wanted

tanchaozhen avatar Nov 27 '19 02:11 tanchaozhen

Please refer to the readme. 4-3-1. For 2D images Dimension of images: (Width, Height, Channels)

Your input should be 3 channels (512, 512, 1)

Cheng-Lin-Li avatar Nov 27 '19 14:11 Cheng-Lin-Li

I step through the code. in load_2d_data.py line84, "mask = convert_mask_data(mask)" convert mask images to NPZ,Then,in custom_data_aug.py line238 "change_background_color" need 4 channels( Convert mask color of 4 channels png image to new color ).I checked coco's mask is 4 channel, so it works. For my data, mask is 2D (512,512) binary image, I annotated line84 “convert_mask_data” line instead of adding mask=np.expand_dim(mask,-1) to make mask being (512,512,1).so It works for my data.

tanchaozhen avatar Nov 30 '19 08:11 tanchaozhen

Then,I trained my data,but val_out_seg_dice_hard did not improve from 0.42 after 2 epoch, and test result is error. First, I suspect there are some problems for my input data after modifing your code.So, I downloaded 1000 coco images and trained them with the original code. The parameters is --train --initial_lr 0.001 --net segcapsr3 --loss dice --data_root_dir=data_coco --which_gpus=0 --dataset mscoco17 --epoch=20. However,val_out_seg_dice_hard did not improve from 0.39148 for epoch 14,and test results are quite different from groundtruth.

996/1000 [============================>.] - ETA: 4s - loss: 0.7128 - out_seg_loss: 0.6852 - out_recon_loss: 0.0276 - out_seg_dice_hard: 0.1990INFO 2019-11-30 16:02:46,381: path_to_np=data_coco\np_files\train474.npz

997/1000 [============================>.] - ETA: 3s - loss: 0.7129 - out_seg_loss: 0.6852 - out_recon_loss: 0.0276 - out_seg_dice_hard: 0.1989INFO 2019-11-30 16:02:47,458: path_to_np=data_coco\np_files\train951.npz

998/1000 [============================>.] - ETA: 2s - loss: 0.7127 - out_seg_loss: 0.6851 - out_recon_loss: 0.0276 - out_seg_dice_hard: 0.1990INFO 2019-11-30 16:02:48,536: path_to_np=data_coco\np_files\train776.npz

999/1000 [============================>.] - ETA: 1s - loss: 0.7125 - out_seg_loss: 0.6849 - out_recon_loss: 0.0276 - out_seg_dice_hard: 0.1990INFO 2019-11-30 16:02:49,680: path_to_np=data_coco\np_files\train957.npz

1000/1000 [==============================] - 1082s 1s/step - loss: 0.7122 - out_seg_loss: 0.6846 - out_recon_loss: 0.0276 - out_seg_dice_hard: 0.1995 - val_loss: 0.6265 - val_out_seg_loss: 0.5915 - val_out_recon_loss: 0.0351 - val_out_seg_dice_hard: 0.3270

Epoch 00014: val_out_seg_dice_hard did not improve from 0.39148 Epoch 15/20

I adjust the cords,such as initial_lr, loss. The effects did not improved. Any advice would be appreciated. @Cheng-Lin-Li

tanchaozhen avatar Nov 30 '19 08:11 tanchaozhen