bethgelab/siamese-mask-rcnn

The problem occurred in train.ipynb

Closed this issue · 2 comments

Create model object in inference mode.

model = siamese_model.SiameseMaskRCNN(mode="training", model_dir=MODEL_DIR, config=config)
ValueError Traceback (most recent call last)
in ()
1 # Create model object in inference mode.
----> 2 model = siamese_model.SiameseMaskRCNN(mode="training", model_dir=MODEL_DIR, config=config)

~/disk/ZSD/new_version_one_shot_instance_seg/lib/Mask_RCNN/mrcnn/model.py in init(self, mode, config, model_dir)
1830 self.model_dir = model_dir
1831 self.set_log_dir()
-> 1832 self.keras_model = self.build(mode=mode, config=config)
1833
1834 def build(self, mode, config):

~/disk/ZSD/new_version_one_shot_instance_seg/lib/model.py in build(self, mode, config)
294 # CHANGE: add siamese distance copmputation
295 # Combine FPs using L1 distance
--> 296 P2 = l1_distance_graph(IP2, TP2, feature_maps = 3self.config.FPN_FEATUREMAPS//2, name='P2')
297 P3 = l1_distance_graph(IP3, TP3, feature_maps = 3
self.config.FPN_FEATUREMAPS//2, name='P3')
298 P4 = l1_distance_graph(IP4, TP4, feature_maps = 3*self.config.FPN_FEATUREMAPS//2, name='P4')

~/disk/ZSD/new_version_one_shot_instance_seg/lib/model.py in l1_distance_graph(P, T, feature_maps, name)
85 T = KL.Lambda(lambda x: K.expand_dims(K.expand_dims(x, axis=1), axis=1))(T)
86 # T = KL.Lambda(lambda x: K.tile(T, [1, int(P.shape[1]), int(P.shape[2]), 1]))(T)
---> 87 L1 = KL.Subtract()([P, T])
88 L1 = KL.Lambda(lambda x: K.abs(x))(L1)
89 D = KL.Concatenate()([P, L1])#KL.Concatenate()([P, T, L1])

~/disk/anaconda3/envs/py36/lib/python3.6/site-packages/keras/engine/topology.py in call(self, inputs, **kwargs)
600
601 # Actually call the layer, collecting output(s), mask(s), and shape(s).
--> 602 output = self.call(inputs, **kwargs)
603 output_mask = self.compute_mask(inputs, previous_mask)
604

~/disk/anaconda3/envs/py36/lib/python3.6/site-packages/keras/layers/merge.py in call(self, inputs)
144 return y
145 else:
--> 146 return self._merge_function(inputs)
147
148 def compute_output_shape(self, input_shape):

~/disk/anaconda3/envs/py36/lib/python3.6/site-packages/keras/layers/merge.py in _merge_function(self, inputs)
241 'on exactly 2 inputs')
242 if inputs[0]._keras_shape != inputs[1]._keras_shape:
--> 243 raise ValueError('Subtract layer should be called '
244 'on inputs of the same shape')
245 return inputs[0] - inputs[1]

ValueError: Subtract layer should be called on inputs of the same shape

But when I convert the file "train.ipynb" into “train.py”,it can run successfully.

I was not able to reproduce this issue and will thus close it now! Please let me know if anyone else runs into the same problem!