seanbell / intrinsic

Code for Bell et al, "Intrinsic Images in the Wild", SIGGRAPH 2014.
MIT License
153 stars 33 forks source link

error when i run the script #6

Closed philleer closed 5 years ago

philleer commented 5 years ago

After git clone the repo from the github I have install the dependecies as the instruction image And I also compile it successfully But when I tried to run the script I got such error

Traceback (most recent call last):
  File "bell2014/decompose.py", line 22, in <module>
    from bell2014.solver import IntrinsicSolver
  File "/home/SENSETIME/lipenghui/mycode/intrinsic_test/bell2014/solver.py", line 8, in <module>
    from .decomposition import IntrinsicDecomposition
  File "/home/SENSETIME/lipenghui/mycode/intrinsic_test/bell2014/decomposition.py", line 3, in <module>
    from . import image_util
  File "/home/SENSETIME/lipenghui/mycode/intrinsic_test/bell2014/image_util.py", line 5, in <module>
    from skimage.filter import denoise_bilateral
ImportError: No module named filter

Here is my system configuration

Description:    Ubuntu 16.04.6 LTS
Codename:    xenial
Graphics:       GeForce GTX 1060 6GB/PCIe/SSE2
OS Type:       64-bit
Python 2.7.12 (default, Nov 12 2018, 14:36:49) 
[GCC 5.4.0 20160609] on linux2
numpy==1.16.4
scipy==1.2.1
matplotlib==2.2.4
cython==0.29.10
pillow==6.0.0
PIL==6.0.0
scikit-image==0.14.2
scikit-learn==0.20.3

So what should I do to make it work? Have anyone encountered such problem? Any help is much appreciated. Thx very much!

seanbell commented 5 years ago

If you notice, I was on version 0.9.3 and you're on 0.14.2 for the scikit-image package. The module (skimage) moved the submodule filter elsewhere in a later version. You could either change the import line in the intrinsic code to grab the new version of the filter, or you could downgrade your scikit-image package (or you could set up a Python virtual env and use the exact same versions there).

It looks like for version 0.14.*, it's now in restoration rather than filter: https://scikit-image.org/docs/0.14.x/api/skimage.restoration.html?highlight=denoise_bilateral#skimage.restoration.denoise_bilateral. I don't know if they also changed the implementation of the filter, you'd have to check that across versions.

philleer commented 5 years ago

Yes, you're totally right. Shortly after I opened this issue, I have tried to downgrade all my package to your suggested version or similar to it.

Here is it

>>> Python 3.5.2 (default, Nov 12 2018, 13:43:14) 
>>> [GCC 5.4.0 20160609] on linux
>>> Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import scipy
>>> import skimage
>>> import sklearn
>>> import PIL
>>> numpy.__version__
'1.8.2'
>>> scipy.__version__
'1.0.0'
>>> skimage.__version__
'0.9.3'
>>> sklearn.__version__
'0.19.0'
>>> PIL.__version__
'6.0.0'

And for python3, there are something different from python2, such as

Meanwhile, I also encountered the Unicode Decode Error
According to the traceback, the error date back to this line of file "bell2014/energy/prob_abs_r.py"

self.density = pk.load(gzip.open(data_filename, "rb"))
Traceback (most recent call last):
  File "bell2014/decompose.py", line 125, in <module>
    solver = IntrinsicSolver(input, params)
  File "/home/cv/mycode/github/intrinsic_test/bell2014/solver.py", line 26,in __init__
    self.energy = IntrinsicEnergy(self.input, params)
  File "/home/cv/mycode/github/intrinsic_test/bell2014/energy/energy.py", line 14, in __init__
    self.prob_abs_r = ProbAbsoluteReflectance(params)
  File "/home/cv/mycode/github/intrinsic_test/bell2014/energy/prob_abs_r.py", line 16, in __init__
    self._load()
  File "/home/cv/mycode/github/intrinsic_test/bell2014/energy/prob_abs_r.py", line 66, in _load
    self.density = pk.load(gzip.open(data_filename, "rb"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xfe in position 0: ordinal not in range(128)

Seems like codec issue, so I first tried utf-8

f = gzip.open(data_filename, "rb")
self.density = pk.load(f, encoding='utf-8')
f.close()

Still error but something different

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfe in position 0: invalid start byte

Then I tried iso-8859-1

f = gzip.open(data_filename, "rb")
self.density = pk.load(f, encoding='iso-8859-1')
f.close()

All right, it is ok now. ( Though I dont know the cause of it, is it due to my ubuntu system configuration or something else such as terminal decoder? ) Anyway, it works well finally.

Still much thx to your reply.