deepvisualminer icon indicating copy to clipboard operation
deepvisualminer copied to clipboard

cv2.error: /io/opencv/modules/core/src/lda.cpp At least two classes are needed to perform a LDA

Open xtaylord opened this issue 7 years ago • 2 comments

Hello, I'm having an issue with the training stage, using the command: sudo docker run --rm
-v $(pwd)/resized:/root/resized
-v $(pwd)/reports:/root/reports
-v $(pwd)/catsmodel:/root/catsmodel
pathbreak/deepvisualminer
python3 /root/deepvisualminer/facerec_train.py train /root/reports/dataset.csv
80 /root/reports/testset.csv /root/catsmodel 1 1 1 The error I'm getting is shown below, any ideas?

Eigen done Traceback (most recent call last): File "/root/deepvisualminer/facerec_train.py", line 487, in train( sys.argv[2], int(sys.argv[3]), sys.argv[4], sys.argv[5], bool(sys.argv[6]), bool(sys.argv[7]), bool(sys.argv[8]) ) File "/root/deepvisualminer/facerec_train.py", line 215, in train fischer_recog.train(train_images, training_labels) cv2.error: /io/opencv/modules/core/src/lda.cpp:1018: error: (-5) At least two classes are needed to perform a LDA. Reason: Only one class was given! in function lda

Thanks D

xtaylord avatar Jun 29 '18 21:06 xtaylord

@xtaylord Thank you very much for using my software and taking the time to report this !

The "At least two classes..." is referring to number of labels (cats in this case) in the dataset.

It turns out to be a bug in my software where I'm not handling the entirely common possibility that a user may have only one cat and is training the model to recognize that single cat in photos (in my defense, I've always had more than one cat and never even tested for single cat recognition :D).

Basically, the software trains three alternative algorithms, and one of those - FischerFaces - requires a minimum of two labels/cats.

What you can do now: Disable FischerFaces algorithm during training, testing and mining.

  1. Training: Use this command line (note that the second last argument is now 0 instead of 1 to disable FischerFaces):
sudo docker run --rm
-v $(pwd)/resized:/root/resized
-v $(pwd)/reports:/root/reports
-v $(pwd)/catsmodel:/root/catsmodel
pathbreak/deepvisualminer
python3 /root/deepvisualminer/facerec_train.py train /root/reports/dataset.csv
80 /root/reports/testset.csv /root/catsmodel 1 0 1
  1. Testing: Same change as training
sudo docker run --rm \
  -v $(pwd)/resized-334x311:$(pwd)/resized-334x311 \
  -v $(pwd)/reports:/root/reports \
  -v $(pwd)/catsmodel:/root/catsmodel \
  deepvisualminer \
  python3 /root/deepvisualminer/facerec_train.py test \
    /root/reports/testset.csv /root/catsmodel 1 0 1

  1. Mining: In your pipeline configuration YAML file, remove FischerFaces from strategies and set outputlabel to eigen or lbp or mostvotes. Example:
- name: cat-face-recognizer
  type: recognizer
  inputs: 
  - files
  
  params:
  
    # The model directory where model files were generated during training.
    model: /root/models/mycats/
    
    # strategies: list of recognizers to run. one or more of [eigen, fischer, lbp]
    strategies:
    - eigen
    - lbp
    # output : which labels to output. Can be one of [all, mostvotes, <strategies>] where
    # 
    # "all" means outputs of all strategies
    # "mostvotes" means single output which has most votes from multiple strategies. If there'
    #       no clear majority, it'll output all.
    # "<strategies>" means output of one or more of the strategies above. 
    #       For example, 
    #           output: 
    #           - lbp
    #           - eigen
    #       means include only outputs of lbp and eigen in the outputs.
    outputlabel: 
    - eigen
...

From my side, I'll make corrections to handle single cat (or single label of any kind), but this may take some days.

Any other feedback and suggestions are very welcome.

pathbreak avatar Jul 01 '18 12:07 pathbreak

Thanks Karthik,

I'll do some testing later in the week!

Cheers

Dan


From: Karthik Shiraly [email protected] Sent: 01 July 2018 13:40 To: pathbreak/deepvisualminer Cc: xtaylord; Mention Subject: Re: [pathbreak/deepvisualminer] cv2.error: /io/opencv/modules/core/src/lda.cpp At least two classes are needed to perform a LDA (#1)

@xtaylordhttps://github.com/xtaylord Thank you very much for using my software and taking the time to report this !

The "At least two classes..." is referring to number of labels (cats in this case) in the dataset.

It turns out to be a bug in my software where I'm not handling the entirely common possibility that a user may have only one cat and is training the model to recognize that single cat in photos (in my defense, I've always had more than one cat and never even tested for single cat recognition :D).

Basically, the software trains three alternative algorithms, and one of those - FischerFaces - requires a minimum of two labels/cats.

What you can do now: Disable FischerFaces algorithm during training, testing and mining.

  1. Training: Use this command line (note that the second last argument is now 0 instead of 1 to disable FischerFaces):

sudo docker run --rm -v $(pwd)/resized:/root/resized -v $(pwd)/reports:/root/reports -v $(pwd)/catsmodel:/root/catsmodel pathbreak/deepvisualminer python3 /root/deepvisualminer/facerec_train.py train /root/reports/dataset.csv 80 /root/reports/testset.csv /root/catsmodel 1 0 1

  1. Testing: Same change as training

sudo docker run --rm
-v $(pwd)/resized-334x311:$(pwd)/resized-334x311
-v $(pwd)/reports:/root/reports
-v $(pwd)/catsmodel:/root/catsmodel
deepvisualminer
python3 /root/deepvisualminer/facerec_train.py test
/root/reports/testset.csv /root/catsmodel 1 0 1

  1. Mining: In your pipeline configuration YAML file, remove FischerFaces from strategies and set outputlabel to eigen or lbp or mostvotes. Example:
  • name: cat-face-recognizer type: recognizer inputs:

    • files

    params:

    The model directory where model files were generated during training.

    model: /root/models/mycats/

    strategies: list of recognizers to run. one or more of [eigen, fischer, lbp]

    strategies:

    • eigen
    • lbp

    output : which labels to output. Can be one of [all, mostvotes, ] where

    "all" means outputs of all strategies

    "mostvotes" means single output which has most votes from multiple strategies. If there'

    no clear majority, it'll output all.

    "" means output of one or more of the strategies above.

    For example,

    output:

    - lbp

    - eigen

    means include only outputs of lbp and eigen in the outputs.

    outputlabel:

    • eigen ...

From my side, I'll make corrections to handle single cat (or single label of any kind), but this may take some days.

Any other feedback and suggestions are very welcome.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/pathbreak/deepvisualminer/issues/1#issuecomment-401604204, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFu2G8LobAQjs2RVjtbYWibcd-qaXgacks5uCMMngaJpZM4U9p7h.

xtaylord avatar Jul 03 '18 21:07 xtaylord