machine-shop / mothra

Automated butterfly wing length measurement
Other
27 stars 15 forks source link

Cannot generate plot when combining `-p`/`-pp` and `-s 'measurements'` #48

Closed alexdesiqueira closed 4 years ago

alexdesiqueira commented 4 years ago

I can't generate a plot when combining -p/-pp and -s 'measurements'. Code breaks when running pipeline.py, line 197: points_interest = tracing.main(bfly_bin, axes). it raises this issue when receiving axes=None.

Command used: $ python pipeline.py -pp -i butterfly/tests/test_files/test_input/BMNHE_500607.JPG

(part of the) Traceback:

Traceback (most recent call last):
  File "pipeline.py", line 217, in <module>
    main()
  File "pipeline.py", line 197, in main
    points_interest = tracing.main(bfly_bin, axes)
  File "/home/alex/miniconda3/lib/python3.7/site-packages/joblib/memory.py", line 565, in __call__
    return self._cached_call(args, kwargs)[0]
(...)
  File "/home/alex/miniconda3/lib/python3.7/site-packages/numpy/ma/core.py", line 3154, in view
    output = ndarray.view(self, dtype)
  File "/home/alex/miniconda3/lib/python3.7/site-packages/numpy/ma/core.py", line 3375, in dtype
    self._mask.shape = self.shape
ValueError: cannot reshape array of size 10 into shape (5,16)

Maybe there's something wrong with joblib...? Tested with two joblib versions: 0.14.1, 0.15.1. Thank you!

alexdesiqueira commented 4 years ago

For the record, code works properly when not using -p/-pp:

$ python pipeline.py -i butterfly/tests/test_files/test_input/BMNHE_500607.JPG
Image 1/1 : BMNHE_500607.JPG
Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning.
Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning.
left_wing : 13.61 mm
right_wing : 13.66 mm
left_wing_center : 17.31 mm
right_wing_center : 17.28 mm
wing_span : 28.98 mm
stefanv commented 4 years ago

Yes, I had the same issue.

stefanv commented 4 years ago

This should be fixed now; please verify.

alexdesiqueira commented 4 years ago

Thanks, Stéfan. I'm having issues with repeated executions, though; an example.

$ python pipeline.py -s 'measurements' -pp -i butterfly/tests/test_files/test_input/BMNHE_500607.JPG
Image 1/1 : BMNHE_500607.JPG
left_wing : 13.57 mm
right_wing : 13.66 mm
left_wing_center : 17.3 mm
right_wing_center : 17.29 mm
wing_span : 28.98 mm

BMNHE_500607

$ python pipeline.py -s 'measurements' -pp -i butterfly/tests/test_files/test_input/BMNHE_500607.JPG
Image 1/1 : BMNHE_500607.JPG
left_wing : 13.57 mm
right_wing : 13.66 mm
left_wing_center : 17.3 mm
right_wing_center : 17.29 mm
wing_span : 28.98 mm

BMNHE_500607

I have to remove cachedir and output after each run to generate new results. Let me test with more than one image.

stefanv commented 4 years ago

Yeap, check the commit log :)

alexdesiqueira commented 4 years ago

Saw it now. Sorry about that :sweat_smile: Closing this then. Solved by fe0cb8. Thank you Stéfan!