EvilPort2 / Sign-Language

A very simple CNN project.
764 stars 356 forks source link

gestures folder images are broken? #12

Open monajalal opened 6 years ago

monajalal commented 6 years ago

I think the images have problem. They are all black. Anyway, I get this error. Can you please help how to fix?

$ python set_hand_hist.py
OpenCV Error: Assertion failed ((scn == 3 || scn == 4) && (depth == 0 || depth == 5)) in cvtColor, file /tmp/build/80754af9/opencv_1512687413662/work/modules/imgproc/src/color.cpp, line 11115
Traceback (most recent call last):
  File "set_hand_hist.py", line 70, in <module>
    get_hand_hist()
  File "set_hand_hist.py", line 38, in get_hand_hist
    hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
cv2.error: /tmp/build/80754af9/opencv_1512687413662/work/modules/imgproc/src/color.cpp:11115: error: (-215) (scn == 3 || scn == 4) && (depth == 0 || depth == 5) in function cvtColor

screenshot from 2018-06-10 22-05-46

[jalal@goku Sign-Language]$ python
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 13 2017, 12:02:49) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.3.1'
monajalal commented 6 years ago

Installed OpenCV 3.4.1 and still get the same error:

[jalal@goku Sign-Language]$ conda install -c conda-forge opencv 

Solving environment: done

## Package Plan ##

  environment location: /scratch/sjn/anaconda

  added / updated specs: 
    - opencv

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    conda-4.5.4                |           py36_0         621 KB  conda-forge
    certifi-2018.4.16          |           py36_0         142 KB  conda-forge
    scipy-1.1.0                |py36_blas_openblas_200        40.2 MB  conda-forge
    ------------------------------------------------------------
                                           Total:        41.0 MB

The following packages will be UPDATED:

    blas:            1.0-mkl               anaconda --> 1.1-openblas                  conda-forge
    ca-certificates: 2018.03.07-0          anaconda --> 2018.4.16-0                   conda-forge
    certifi:         2018.4.16-py36_0      anaconda --> 2018.4.16-py36_0              conda-forge
    conda:           4.5.4-py36_0          anaconda --> 4.5.4-py36_0                  conda-forge
    numpy:           1.13.3-py36hdbf6ddf_4 anaconda --> 1.13.3-py36_blas_openblas_201 conda-forge [blas_openblas]
    opencv:          3.3.1-py36h6cbbc71_1  anaconda --> 3.4.1-py36_blas_openblas_200  conda-forge [blas_openblas]
    openssl:         1.0.2o-h20670df_0     anaconda --> 1.0.2o-0                      conda-forge
    scikit-learn:    0.19.1-py36h7aa7ec6_0 anaconda --> 0.19.1-py36_blas_openblas_201 conda-forge [blas_openblas]
    scipy:           1.1.0-py36hfc37229_0  anaconda --> 1.1.0-py36_blas_openblas_200  conda-forge [blas_openblas]

The following packages will be DOWNGRADED:

    ffmpeg:          3.4-h7264315_0        anaconda --> 3.2.4-2                       conda-forge

Proceed ([y]/n)? 

Downloading and Extracting Packages
conda-4.5.4          |  621 KB | ########################################################################################## | 100% 
certifi-2018.4.16    |  142 KB | ########################################################################################## | 100% 
scipy-1.1.0          | 40.2 MB | ########################################################################################## | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
[jalal@goku Sign-Language]$ python
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 13 2017, 12:02:49) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.4.1'
>>> quit()
[jalal@goku Sign-Language]$ python set_hand_hist.py
OpenCV(3.4.1) Error: Assertion failed ((scn == 3 || scn == 4) && (depth == 0 || depth == 5)) in cvtColor, file /feedstock_root/build_artefacts/opencv_1520722599420/work/opencv-3.4.1/modules/imgproc/src/color.cpp, line 11214
Traceback (most recent call last):
  File "set_hand_hist.py", line 70, in <module>
    get_hand_hist()
  File "set_hand_hist.py", line 38, in get_hand_hist
    hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
cv2.error: OpenCV(3.4.1) /feedstock_root/build_artefacts/opencv_1520722599420/work/opencv-3.4.1/modules/imgproc/src/color.cpp:11214: error: (-215) (scn == 3 || scn == 4) && (depth == 0 || depth == 5) in function cvtColor
EvilPort2 commented 6 years ago

the '0/' folder is supposed to contain blank images. that folder is not broken. due to some reason keeping those blank images increased my accuracy to ~99%.

as for the error in set_hand_hist.py, i think you are using an old version of this project. that error happens when the img variable is None. it happened due to a bug in the code. but it was fixed later. so try recloning the repo.

in case that does not work, see if your laptop's/computer's camera is connected properly and is working with some other application like skype.

EvilPort2 commented 6 years ago

@monajalal I have updated the repo. Now the blank images are removed. Maybe the presence of blank images made the accuracy higher was either due bad hyperparameter selection or a bad model.

The new model thus created is:-

  1. Smaller in size (from a huge 8.78MB to 649kB).
  2. Faster (Prediction time decreased).
  3. Better (Can predict you gesture even if you flip your hands).

Also I did some minor memory tweaks so that the load_images.py take much less memory during execution.

monajalal commented 6 years ago

I literally used the code right when I wrote this issue. Can you please push the newer and working version of the project?

EvilPort2 commented 6 years ago

I have updated the repo. The new code is pushed. I am facing no such problem set_hand_hist.py file. It is working just fine for me.

EvilPort2 commented 6 years ago

See this video if you are unable to use the set_hand_hist.py. https://www.youtube.com/watch?v=KYfBLeYDMW4&feature=youtu.be