p2irc / deepplantphenomics

Deep learning for plant phenotyping.
GNU General Public License v2.0
133 stars 46 forks source link

TypeError when using tools #51

Closed tbayetird closed 3 years ago

tbayetird commented 4 years ago

Hi,

I'm having the same error whenever I try to use any or your tools from the tools class.

System information :

Code :

`import deepplantphenomics as dpp import numpy as np from PIL import Image import os

output_dir = 'D:\workspace\plant\images'

my_files = ["D:\workspace\plant\images\exemple1.jpg"]

y = dpp.tools.count_canola_flowers(my_files)`

Error message : Traceback (most recent call last): File "D:\workspace\plant\test.py", line 10, in y = dpp.tools.count_canola_flowers(my_files) File "D:\workspace\plant\deepplantphenomics\tools.py", line 49, in count_canola_flowers predictions = net.forward_pass(x) File "D:\workspace\plant\deepplantphenomics\networks.py", line 253, in forward_pass y = self.model.forward_pass_with_interpreted_outputs(x) File "D:\workspace\plant\deepplantphenomics\countception_object_counter_model.py", line 254, in forward_pass_with_interpreted_outputs xx = self.forward_pass_with_file_inputs(x) File "D:\workspace\plant\deepplantphenomics\countception_object_counter_model.py", line 240, in forward_pass_with_file_inputs x_pred = self.forward_pass(image_data, deterministic=True) File "D:\workspace\plant\deepplantphenomics\deepplantpheno.py", line 1106, in forward_pass x = layer.forward_pass(x, deterministic) File "D:\workspace\plant\deepplantphenomics\layers.py", line 62, in forward_pass padding=self.padding) File "C:\Users\tbaye\Miniconda3\lib\site-packages\tensorflow\python\ops\gen_nn_ops.py", line 1027, in conv2d padding = _execute.make_str(padding, "padding") File "C:\Users\tbaye\Miniconda3\lib\site-packages\tensorflow\python\eager\execute.py", line 110, in make_str (arg_name, repr(v))) TypeError: Expected string for argument 'padding' not [[0, 0], [32, 32], [32, 32], [0, 0]].

the last line veries depending on the tools i'm using :

Thanks in advance !

jubbens commented 4 years ago

I was unable to reproduce this using TF 1.12 under Linux, although I don't have access to a Windows installation to replicate your exact environment. Did you find a solution?

tbayetird commented 4 years ago

Hi, Thank you for your concern !

I recently found a way around. The problem laid in in deepplantphenomics/layers.py. The definition of padding was as follow :

` padding = [[0, 0], [padding_row, padding_row], [padding_col, padding_col], [0, 0]]

    self.padding = str(padding)`

I switch this code for :

` # padding = [[0, 0], [padding_row, padding_row], [padding_col, padding_col], [0, 0]]

    # self.padding = str(padding)

    self.padding = 'SAME'`

Using this fix it worked. Although, I found the vegetation segmentation tool to be lacking on perf on some sample data. Do you perhaps have some examples of your own that I could also try to see if the tool is working properly ?

Anyway, thank you for your work, sharing it and coming for help !