LET: Thresholding causes an exception
Opened this issue · 6 comments
I tried clicking on the scissor icon labeled "Toggles if the threshold for the image is shown or not" but it gave me the following:
Calculating density model...
Traceback (most recent call last):
File "/home/ytan/Dev/handwriting/helit/handwriting/let/let.py", line 743, in __threshold_visible
self.run_threshold()
File "/home/ytan/Dev/handwriting/helit/handwriting/let/let.py", line 684, in run_threshold
_, self.density = threshold.cluster_colour(image, size=self.threshold_cluster_size, halves=self.threshold_cluster_halves)
File "/home/ytan/Dev/handwriting/helit/handwriting/let/threshold.py", line 352, in cluster_colour
tps.learn(dm_x * scale, dm_y)
File "/home/ytan/Dev/handwriting/helit/handwriting/let/misc/tps.py", line 47, in learn
assert(y!=None or (a!=None and b!=None))
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Have pushed a commit that should fix this - my density model estimation code was using a numpy feature that is now depreciated. High risk of further issues of this nature elsewhere in the code, so please report them!
Thanks! This is embarrassing, but I have limited experience with Python so it's tricky to get around.
Now I'm also getting this error message:
let.py:16: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
from gi.repository import Gtk, Gdk, GdkPixbuf, Pango
I think that is a warning and can be ignored? Does it otherwise work?
It opens, but when I tried to click on the "scissor" icon I get this:
Calculating density model...
Calculating density map...
Regularising density map...
Traceback (most recent call last):
File "/home/ytan/Dev/handwriting/helit/handwriting/let/let.py", line 743, in __threshold_visible
self.run_threshold()
File "/home/ytan/Dev/handwriting/helit/handwriting/let/let.py", line 690, in run_threshold
density = threshold.density_median(density, 2, 1.0)
File "/home/ytan/Dev/handwriting/helit/handwriting/let/threshold.py", line 190, in density_median
weave.inline(code, ['density', 'ret', 'radius', 'exp_weight'], support_code=support)
NameError: global name 'weave' is not defined
It appears scipy.weave was available in version 18 but has now been depreciated in 19, which is extremely annoying. You should be able to install weave from https://github.com/scipy/weave or using "pip install weave", though might have to adjust the import statement as I'm not sure if its package name remains the same.
I'll give that a go. Thanks!