Skip to content
David Abigt edited this page Apr 2, 2023 · 9 revisions

DeepStack utils.

Note I have moved the training data and sample model to its own repo to keep this one from becoming too large as I expand the model.

Example of the thought process in selecting images from your cameras and merging with datasets from the web.

Integrations

Utils

Program for merging the output of quickLabel (after being verified) with the data in trainPath

USAGE: chkClasses [-h] [minCount] [trainPath]
 where 'minCount' is the minimum number of training images required to keep a class
 if 'minCount' is -1 or no args passed, only a report is performed on trainPath.
 'minCount' is required if 'trainPath' is passed.
 if 'trainPath' is passed then it overrides the settings for 'trainPath', 'labeled', 'unlabeled' and 'debugPath' in common.py to have the same parent as 'trainPath'
Updates file using object lists objName+'.lst.txt' in 'debugPath'
if not in 'report only; mode does the following:
At start moves images in 'unlabeled' to 'labeled' folder
Creates new merged classes file with those not meeting 'minCount' removed
Creates class ID mapping table and saves a copy to classes.map.txt in 'labeled' folder
Images and maps that do not use the filtered classes are remapped to the new class IDs and moved to 'trainPath'
The unaltered classes.txt plus images and maps that do use the filtered classes are left in the labeled' folder in case needed later

Has unit test

USAGE: cpClasses classNameSubString toPath [fromPath]
If 'fromPath' not passed then defaults to trainPath defined in common.py  
Finds all the class IDs in 'fromPath'/train/classes.txt which have names that include 'classNameSubString'
Copies 'fromPath'/train/classes.txt to 'toPath'/train/classes.txt to use automated merge later
Creates or updates 'toPath'/train/classes.txt with the class names being used to copy
Then finds all the mapping files in 'fromPath'/train folder using those IDs and copies them and their matching image files to 'toPath'/labeled
Then finds all the mapping files in 'fromPath'/test folder using those IDs and copies them and their matching image files to 'toPath'/labeled
Then finds all the mapping files in 'fromPath'/valid folder using those IDs and copies them and their matching image files to 'toPath'/labeled

Has unit test

USAGE: dumpMaps [-h] fromPath
-h prints this help
Finds all the class IDs in 'fromPath'(/train)/classes.txt
Creates cropped images for each label in the image file maps in 'fromPath'/train, 'fromPath'/labeled and 'fromPath'/test  to 'debugPath'/dump/label name

A quick test to make sure all the APIs in your setup are working. Including the 4 custom models in the DeepStack documentation. Note their online documentation has a lot of errors in it.

Bat file to bring up my Jupyter Notebook for training with local GPU.

USAGE: mergeClasses [-h] trainPath
-h prints this help
Creates class ID mapping table between classes.txt and classes.txt.old then saves a copy to classes.map.txt in 'trainPath' folder
Remaps mappings in mapping files for classes names in classes.txt.old in classes.txt then saves a copy of classes.txt with dups removed to 'trainPath' folder.
Mainly used to merge classes like types of dog to just dog.
Note since this updates files directly there is no backup option.

Has unit test

USAGE: pascalvoc2yolo [inputFolderPath] [outputFolderPath]
 where 'inputFolderPath' is the folder with images with their pascalvoc maps in it
 where 'outputFolderPath' is the folder where yolov5 maps will be put
 if 'inputFolderPath' is not passed then it uses the 'newPicPath' settings in common.py
 if 'outputFolderPath' is not passed then it uses inputFolderPath/../labeled
 if 'outputFolderPath' is passed then 'inputFolderPath' is required

Shell script for starting DeepStack with params needed for running tests.

Test that Torch setup is working and using your GPU ready to train.

Has unit test

Runs images passed against the models listed in tests2Run and generates a labeled copy for each with each model's labels in a diff color.

USAGE: testImg imageFilePath [imageFilePath...]

Sample output image

USAGE: trainTest [-h] [trainedName] [trainPath]
-h prints this help
if 'trainedName' and or 'trainPath' are not passed then the values in config.py are used
if trainPath is passed, /train is appended if not there then updates testPath to 'trainPath'../test, validPath to 'trainPath'../valid, labeled to 'trainPath'../labeled, unlabeled to 'trainPath'../unlabeled and debugPath to 'trainPath'../debug.pics
Runs all the images in trainPath, testPath and validPath against the model (trainedName) to see where weakness are to help in adjusting image maps and or removing classes and or images that reduce accuracy.
Creates images in 'debugPath' match the object in the file name.
Image files that did not match are marked up with found in green and expected in red
Matching map files matching the found data are saved to 'debugPath' as well
Lastly image name and confidence list files are created for each object class and 'EMPTY' (no objects in image) named [object class].lst.txt

Shell script for updating then starting DeepStack with params needed for running tests.

Runs pics in newPicPath against all the installed object detect models to generate tag files similar to what the labelImg would produce along with a list of all found objects (classes.txt).

Program for removing poor performing or conflicting classes from the data in trainPath