Skip to content

Quick Label

David Abigt edited this page Jan 11, 2022 · 3 revisions

This process should speed up labeling objects in pics quite a bit. And allow you to to train your custom model with only the objects from other custom models you care about and name them how you wish. In most cases you should be able to just change the object name for any that are wrong. Pics and mapping files are copied to folder named by the variable labeled for review. If no objects were found they are copied to a folder named by the variable unlabeled for manual processing. If a pic already exists in trainPath then it is ignored.

Steps

  1. Add new pics to the folder newPicPath is pointed at.

  2. Copy classes.txt in trainPath to labeled

  3. Edit the classes.txt in labeled as needed to have all the object names the model should be trained with. Note quickLabel will add any names returned not already in classes.txt. If adding to existing model you need to keep the order and placement at top of any objects in classes.txt before editing or you will invalidate previously done mapping files.

  4. Run python quickLabel.py Note if not adding any new classes you may wish run with tests2Run = ["custom/"+trainedName] to have less to correct in the results.

  5. If not already done, clone labelImg to ..\labelImg.

  6. Run labelImg

  7. Set Change Save Folder to labeled

  8. Open labeled folder

  9. Check each labeled object in each image to verify and adjust labels as needed. (Should mainly be removing dups and changing label names on some discovered objects.

  10. Open unlabeled folder (assuming there are files in there)

  11. Add labeled objects in each image as needed. Remove images if does not contain any training objects

  12. Run python chkClasses.py to see how many examples each class has to train with.

  13. Run python chkClasses.py X where X is the minimum number of required matches. As in python chkClasses.py 2 would only keep classes and move training files if there are at least 2 training examples. Mapping class numbers updated in mapping files before being moved. Run python chkClasses.py -h for more details. Note assumes all the classes in trainPath\classes.txt are used so map files in trainPath do not need to be remapped.

Train

Run testTorch.bat to confirm setup is ready

You are now ready to run training. Locally you can use a script like runTrain.bat

For other training options see DeepStack training

Test

Once done it is a good idea to run trainTest.py to see how well the model works. You can use the pics and mapping files in the debugPath folder to quickly add found objects you missed and adjust mappings for objects in training images that were not found in testing.

For the not found objects look for the files names [training image name].expected.jpg. Note zooming in when viewing the file with labelImg can help with adjusting the maps

Since "extra" objects might be dups, all found object images are saved along with and updated mapping file to the debugPath

Clean up

Object missed can be easily added by copying the mapping file from debugPath

Classes not performing well can be removed with python rmClasses.py Note this backup to labeled

Clone this wiki locally