thaines / helit

My machine learning/computer vision library for all of my recent papers, plus algorithms that I just like.
332 stars 149 forks source link

LET: Thresholding causes an exception #6

Open bot1131357 opened 7 years ago

bot1131357 commented 7 years ago

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()
thaines commented 6 years ago

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!

bot1131357 commented 6 years ago

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
thaines commented 6 years ago

I think that is a warning and can be ignored? Does it otherwise work?

bot1131357 commented 6 years ago

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
thaines commented 6 years ago

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.

bot1131357 commented 6 years ago

I'll give that a go. Thanks!