Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors when running in Colab #81

Closed
nyck33 opened this issue Jul 10, 2019 · 9 comments
Closed

Errors when running in Colab #81

nyck33 opened this issue Jul 10, 2019 · 9 comments

Comments

@nyck33
Copy link

nyck33 commented Jul 10, 2019

I git clone'd both master and 2.0 branches and tried to install but I keep getting a no module name 'deepgaze' error in the face_center_color_classification notebook's first cell.

(base) nobu@gold3forever /media/nobu/Ubuntu Backup1/DeepLearning/PornFlow/deepgaze_py2 (master) $ sudo python setup.py install
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'include_package_data'
  warnings.warn(msg)
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/deepgaze
copying deepgaze/bayes_filter.py -> build/lib.linux-x86_64-2.7/deepgaze
copying deepgaze/cnn_head_pose_estimator.py -> build/lib.linux-x86_64-2.7/deepgaze
copying deepgaze/color_classification.py -> build/lib.linux-x86_64-2.7/deepgaze
copying deepgaze/color_detection.py -> build/lib.linux-x86_64-2.7/deepgaze
copying deepgaze/face_detection.py -> build/lib.linux-x86_64-2.7/deepgaze
copying deepgaze/face_landmark_detection.py -> build/lib.linux-x86_64-2.7/deepgaze
copying deepgaze/haar_cascade.py -> build/lib.linux-x86_64-2.7/deepgaze
copying deepgaze/head_pose_estimation.py -> build/lib.linux-x86_64-2.7/deepgaze
copying deepgaze/mask_analysis.py -> build/lib.linux-x86_64-2.7/deepgaze
copying deepgaze/motion_detection.py -> build/lib.linux-x86_64-2.7/deepgaze
copying deepgaze/motion_tracking.py -> build/lib.linux-x86_64-2.7/deepgaze
copying deepgaze/saliency_map.py -> build/lib.linux-x86_64-2.7/deepgaze
copying deepgaze/__init__.py -> build/lib.linux-x86_64-2.7/deepgaze
running install_lib
running install_egg_info
Removing /usr/local/lib/python2.7/dist-packages/deepgaze-0.1.egg-info
Writing /usr/local/lib/python2.7/dist-packages/deepgaze-0.1.egg-info
@mpatacchiola
Copy link
Owner

Hi @nyck33

There may be a problem with the link to the libraries in your system, with the module not found. Try the following:

After installing deepgaze through sudo python setup.py install open a new terminal. Start a new python console through the command python2 (for Deepgaze 1.0) or python3 (for Deepgaze 2.0). Now just try to import the module writing in the python console import deepgaze. If the module is correctly installed you should not get any error, otherwise please report the error that you get.

@nyck33
Copy link
Author

nyck33 commented Jul 10, 2019

I have it running online in Colab now but getting

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-22-ba7b5b584cba> in <module>()
----> 1 cx, cy = my_mask_analyser.returnMaxAreaCenter(image_mask)
      2 cnt = my_mask_analyser.returnMaxAreaContour(image_mask)

/content/deepgaze/deepgaze/mask_analysis.py in returnMaxAreaCenter(self, mask)

ValueError: too many values to unpack (expected 2)

I was getting another error before that related to def returnMaxAreaCenter() for the line contours, hierarchy = cv2.findContours(mask, 1, 2) so I added a _ in front of contours to make it _, contours, hierarchy = cv2.findContours(mask, 1, 2)

@nyck33 nyck33 changed the title Cannot install nor run Notebooks on Ubuntu 18 Errors when running in Colab Jul 10, 2019
@mpatacchiola
Copy link
Owner

This may be due to incompatibility between the version of Deepgaze installed and the version of OpenCV.
Please check your setup, in particular be sure that you are using OpenCV 2 with Deepgaze 1.0 or OpenCV 3 with Deepgaze 2.0.

@nyck33
Copy link
Author

nyck33 commented Jul 10, 2019 via email

@nyck33
Copy link
Author

nyck33 commented Jul 10, 2019

@mpatacchiola I git cloned 2.0 version with command git clone https://github.com/mpatacchiola/deepgaze.git -b 2.0 --single-branch. Then I checked the opencv version on Colab which turned out to be 3.4.3.
So I should be good to go I thought but still getting the Value Error per below:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-16-f45818827aea> in <module>()
      1 '''for i in range(len(a)):
      2     print(a[i])'''
----> 3 cx, cy = my_mask_analyser.returnMaxAreaCenter(image_mask)
      4 cnt = my_mask_analyser.returnMaxAreaContour(image_mask)

/usr/local/lib/python3.6/dist-packages/deepgaze/mask_analysis.py in returnMaxAreaCenter(self, mask)
     50         if(len(mask.shape) == 3):
     51             mask = cv2.cvtColor(mask, cv2.COLOR_BGR2GRAY)
---> 52         contours, hierarchy = cv2.findContours(mask, 1, 2)
     53         area_array = np.zeros(len(contours)) #contains the area of the contours
     54         counter = 0

ValueError: too many values to unpack (expected 2)

Reverting back to opencv 2 on Colab is a bit of work but I'll give it a shot. Regardless, the notebooks should work with either master (1.0) or 2.0?

@mpatacchiola
Copy link
Owner

Deepgaze 2.0 is still work in progress at the moment and it is possible that there may be a few hidden issues to fix. The notebooks should work with the version 2.0. @kamathhrishi is taking care of the porting at the moment, let's see if he can give a look to it...

@mpatacchiola
Copy link
Owner

@nyck33 for the moment you can simply substitute: contours, hierarchy = cv2.findContours(mask, 1, 2) with _, contours, hierarchy = cv2.findContours(mask, 1, 2) and then install again the library to make the change effective. This should be due to the fact that in OpenCV 3 the function cv2.findContours() now returns 3 values instead of 2. @kamathhrishi I think a simple patch consists in checking the version of OpenCV with a conditional operator and call the appropriate method. Something like this:

import cv2
(major, minor, _) = cv2.__version__.split(".")

if(major=='2'):
    contours, hierarchy = cv2.findContours(mask, 1, 2)
elif(major=='3'):
    _, contours, hierarchy = cv2.findContours(mask, 1, 2)

@nyck33 if you fix it, you can send a pull request on the 2.0 branch and I will add it to the repo.

@nyck33
Copy link
Author

nyck33 commented Jul 11, 2019

@mpatacchiola
I guess you already kind of solved it:)
I was just looking for a way to detect profile faces (side faces) so have to move on at this time but hopefully someone else will find info above useful.

@mpatacchiola
Copy link
Owner

This has now been fixed in branch 2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants