Error with plugin classifypixelsunet

Got the following error with plugin classifypixelsunet. I used your Conda installation in a ec2 with DeepLearning AMI, and added Keras 1.2.2. Thanks

Error detected during run of module ClassifyPixels-Unet
Traceback (most recent call last):
  File "/home/ec2-user/anaconda3/envs/cellprofiler/lib/python2.7/site-packages/cellprofiler/pipeline.py", line 1782, in run_with_yield
    self.run_module(module, workspace)
  File "/home/ec2-user/anaconda3/envs/cellprofiler/lib/python2.7/site-packages/cellprofiler/pipeline.py", line 2034, in run_module
    module.run(workspace)
  File "plugin-unet/classifypixelsunet.py", line 106, in run
    model = unet_initialize(input_shape)
  File "plugin-unet/classifypixelsunet.py", line 121, in unet_initialize
    model = get_model_3_class(dim1, dim2)
  File "plugin-unet/classifypixelsunet.py", line 236, in get_model_3_class
    y = keras.layers.Activation(activation)(y)
  File "/home/ec2-user/anaconda3/envs/cellprofiler/lib/python2.7/site-packages/keras/engine/topology.py", line 572, in __call__
    self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
  File "/home/ec2-user/anaconda3/envs/cellprofiler/lib/python2.7/site-packages/keras/engine/topology.py", line 635, in add_inbound_node
    Node.create_node(self, inbound_layers, node_indices, tensor_indices)
  File "/home/ec2-user/anaconda3/envs/cellprofiler/lib/python2.7/site-packages/keras/engine/topology.py", line 166, in create_node
    output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
  File "/home/ec2-user/anaconda3/envs/cellprofiler/lib/python2.7/site-packages/keras/layers/core.py", line 278, in call
    return self.activation(x)
  File "/home/ec2-user/anaconda3/envs/cellprofiler/lib/python2.7/site-packages/keras/activations.py", line 17, in softmax
    'Here, ndim=' + str(ndim))
ValueError: Cannot apply softmax to a tensor that is not 2D or 3D. Here, ndim=4

The UNet plugin is tested with Keras version > 2.2. Could you try using an updated version?

When I used keras==2.2.4 or 2.2.1, I got the following error.

Error detected during run of module ClassifyPixels-Unet
Traceback (most recent call last):
  File "/home/ec2-user/anaconda3/envs/cellprofiler/lib/python2.7/site-packages/cellprofiler/pipeline.py", line 1782, in run_with_yield
    self.run_module(module, workspace)
  File "/home/ec2-user/anaconda3/envs/cellprofiler/lib/python2.7/site-packages/cellprofiler/pipeline.py", line 2034, in run_module
    module.run(workspace)
  File "plugin-unet/classifypixelsunet.py", line 106, in run
    model = unet_initialize(input_shape)
  File "plugin-unet/classifypixelsunet.py", line 121, in unet_initialize
    model = get_model_3_class(dim1, dim2)
  File "plugin-unet/classifypixelsunet.py", line 231, in get_model_3_class
    [x, y] = get_core(dim1, dim2)
  File "plugin-unet/classifypixelsunet.py", line 199, in get_core
    y = keras.layers.merge([d, c], concat_axis=3, mode="concat")
TypeError: 'module' object is not callable

Can you provide the pipeline and the image used? I can not reproduce the error. One possible error source is the input image. The UNet plugin works with grayscale images. Can you check the image type used in the module?

The same image I sent you via ResearchGate, and the pipeline file you sent me. I am trying to reproduce your result. thanks
201812_youping_xiao.cppipe (19.5 KB)

Original TIF image: download

Hi YX, any luck of making it working? I have the same error message. Thanks.

Hi yx77030

I found out the reason why it’s not working. The keras>2.20 version no longer use
keras.layers.merge([d, c], concat_axis=3, mode=“concat”)
instead, you need to change the code to:
y = keras.layers.merge.concatenate([d, c], axis=3)

there are three lines of this merge layer.

3 Likes