Cheng-Lin-Li / SegCaps

A Clone version from Original SegCaps source code with enhancements on MS COCO dataset.
Apache License 2.0
65 stars 29 forks source link

TypeError: deconv_length() missing 1 required positional argument: 'output_padding' #13

Closed hiteshnitetc closed 5 years ago

hiteshnitetc commented 5 years ago

Traceback (most recent call last): File "./main.py", line 281, in main(arguments) File "./main.py", line 95, in main model_list = create_model(args=args, input_shape=net_input_shape, enable_decoder=True) File "/home/nd/capsnet/SegCaps-master (copy)/utils/model_helper.py", line 29, in create_model model_list = CapsNetR3(input_shape, args.num_class, enable_decoder) File "/home/nd/capsnet/SegCaps-master (copy)/segcapsnet/capsnet.py", line 55, in CapsNetR3 name='deconv_cap_1_1')(conv_cap_4_1) File "/home/nd/anaconda3/lib/python3.6/site-packages/keras/engine/base_layer.py", line 457, in call output = self.call(inputs, **kwargs) File "/home/nd/capsnet/SegCaps-master (copy)/segcapsnet/capsule_layers.py", line 250, in call out_height = deconv_length(self.input_height, self.scaling, self.kernel_size, self.padding) TypeError: deconv_length() missing 1 required positional argument: 'output_padding'

hiteshnitetc commented 5 years ago

Another problem is: "Too many indices for array, skipping files " , with 10 images and mask. but when i load MSCOCO data set with 10 images and mask it working.

Cheng-Lin-Li commented 5 years ago

Hi hiteshnitetc,

How many channels in your mask image? It should be only one channel as gray scale images.

hiteshnitetc commented 5 years ago

@Cheng-Lin-Li Hello, yes my mask images are gray scale only, with channel 1, and keras is set to channel last topology

AfsahS commented 5 years ago

I have same issue, code works fine with MSCOCO dataset, but have same error with different datasets.

AfsahS commented 5 years ago

TypeError: deconv_length() missing 1 required positional argument: 'output_padding'.. This issue can be solved using keras=2.1.6 with python 3.6.x

fenaux commented 5 years ago

Hello, I get the same issue My configuration is : ubuntu 18.04.2, Python 3.6.7, Keras 2.2.4

The data were obtained with python3 getcoco17.py --data_root_dir ../data --category person --annotation_file ../data/annotations/instances_train2017.json --number 10 --id 22228 178040 167494 144599 13800 147865 279422 477861 123512 69578

And then I run python3 ./main.py --test --Kfold 2 --net segcapsr3 --data_root_dir=data --loglevel 2 --which_gpus=-2 --gpus=0 --dataset mscoco17 --weights_path data/saved_models/segcapsr3/split-0_batch-1_shuff-1_aug-0_loss-dice_slic-1_sub--1_strid-1_lr-0.0001_recon-20.0_model_20180705-092846.hdf5

thanks for your help

fenaux commented 5 years ago

Extract from documentation of deconv_length line 148 and 149 https://github.com/keras-team/keras/blob/master/keras/utils/conv_utils.py output_padding: Integer, amount of padding along the output dimension, Can be set to None in which case the output length is inferred

Then I introduced the following modifications in "capsule_layers.py" ddition on line 250 output_padding = None New 251 (was 250) out_height = deconv_length(self.input_height, self.scaling, self.kernel_size, self.padding, output_padding) New 252 (was 252) out_width = deconv_length(self.input_width, self.scaling, self.kernel_size, self.padding, output_padding)

addition on line 284 output_padding = None new 285 (was 283) output_shape[1] = deconv_length(output_shape[1], self.scaling, self.kernel_size, self.padding, output_padding) new 286 (was 284) output_shape[2] = deconv_length(output_shape[2], self.scaling, self.kernel_size, self.padding, output_padding)

and it seems it works. I get 5 output masks But I now have an other issue : "Unable to find weights path. Testing with random weights".

fenaux commented 5 years ago

I found the solution : In test.py Line 109 weights_path = join(args.data_root_dir, args.weights_path) then data should not be repeated in weight_path => command line modified accordingly python3 ./main.py --test --Kfold 2 --net segcapsr3 --data_root_dir=data --loglevel 2 --which_gpus=-2 --gpus=0 --dataset mscoco17 --weights_path saved_models/segcapsr3/split-0_batch-1_shuff-1_aug-0_loss-dice_slic-1_sub--1_strid-1_lr-0.0001_recon-20.0_model_20180705-092846.hdf5

hiteshnitetc commented 5 years ago

Thanku you for your detailed reply, i will try out your suggestions.

On Mon, Jul 15, 2019 at 8:04 PM fenaux notifications@github.com wrote:

I found the solution : In test.py Line 109 weights_path = join(args.data_root_dir, args.weights_path) then data should not be repeated in weight_path => command line modified accordingly python3 ./main.py --test --Kfold 2 --net segcapsr3 --data_root_dir=data --loglevel 2 --which_gpus=-2 --gpus=0 --dataset mscoco17 --weights_path saved_models/segcapsr3/split-0_batch-1_shuff-1_aug-0_loss-dice_slic-1_sub--1_strid-1_lr-0.0001_recon-20.0_model_20180705-092846.hdf5

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Cheng-Lin-Li/SegCaps/issues/13?email_source=notifications&email_token=AHJSSSX4HX2I54ARU3TBRRLP7SDG7A5CNFSM4H6J6QBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ54NIQ#issuecomment-511428258, or mute the thread https://github.com/notifications/unsubscribe-auth/AHJSSSWEEGUGQDGO3J3CQPDP7SDG7ANCNFSM4H6J6QBA .

-- Hitesh Tekchandani PhD Research Scholar NIT Raipur India

Cheng-Lin-Li commented 5 years ago

Hi fenaux,

Thanks for your findings and suggestions. I will revise the document and code accordingly.

tanchaozhen commented 4 years ago

I get the same issue. I solved the first problem "deconv_length() missing " using keras=2.1.6 with python 3.6.x. But,"Too many indices for array, skipping files" still cannot be solved. Have you solved it?

nithinivi commented 3 years ago

TypeError: deconv_length() missing 1 required positional argument: 'output_padding'.. This issue can be solved using keras=2.1.6 with python 3.6.x

If using the latest version of Keras please use output_padding=None, this seems to solve the issue

hiteshnitetc commented 3 years ago

Getting following error.

INFO 2020-12-25 19:49:37,131: 
path_to_np=data/np_files/train18.npz
INFO 2020-12-25 19:49:37,132: 
Pre-made numpy array not found for train18.
Creating now...
DEBUG 2020-12-25 19:49:37,132: STREAM b'IHDR' 16 13
DEBUG 2020-12-25 19:49:37,132: STREAM b'IDAT' 41 32768

----------------------------------------------------------------------------------------------------
Unable to load img or masks for train18
too many indices for array: array is 2-dimensional, but 3 were indexed
Skipping file