$ pip uninstall -y imgaug && pip install git+https://github.com/aleju/imgaug.git
$ git clone https://github.com/asceznyk/oddnet.git
$ cd oddnet/
$ mkdir outputs/ gtruths/model
- outputs is for storing model predictions
- gtruths is for stroing actual images with the ground truth boxes
- link for .weights file https://pjreddie.com/media/files/yolov3.weights
- link for .cfg file https://github.com/pjreddie/darknet/blob/master/cfg/yolov3.cfg
- link for weights https://pjreddie.com/media/files/darknet53.conv.74
- any other format won't work
class1
class2
class3
- each line in the .names file should be used for exactly 1 class
- make sure that it is in a particular order because the model will assign indexes to the classes as follows:
class1 -> 0
class2 -> 1
class3 -> 2
and so on ...
id x y w h
- id: the index of the class
- (x, y, w, h): the xy coordinates and the width and height for the ground truth box (each of these values must be between 0 and 1)
- Plain Object Detection
- Custom Object Detection
$ python detect.py --testdir test --names yournames.labels --cfg yolov3.cfg --weights yolov3.weights --savedir outputs --boxdir gtruths
- testdir: path to the directory with all the test images ONLY
- names: path to the .names file
- cfg: path to model configuration file (this is for model architecture)
- use the yolov3.cfg file you downloaded
- weights: path to .pth or a .weights file you can get this from here
- use the yolov3.weights file you downloaded
- savedir: path to directory to save all the predictions of the model
- boxdir (optional): path to directory to save all the actual images wit ground truth boxes
$ bash createmodel.sh nclasses
- here nclasses is the number of classes
- running this command will create a file called yolov3custom.cfg (this will be used in the next step)
$ !python3 train.py --traindir train/ --validdir valid/ --cfg yolov3custom.cfg --ptweights darknet53.conv.74 --epochs 100 --ckptpth pathtochekpt.pth --lossfn bboxloss --patience 1000
- traindir: path to the directory containing all the training images AND labels
- validdir: path to the directory containing all the validation images AND labels
- cfg: path to the custom model config file created by createmodel.sh (use the yolov3custom.cfg from the previous step)
- ptweights: path to pre-trained weights (use the darknet53.conv.74 weights downloaded, refer step 7 here
- epochs: number of epochs to train the model
- ckptpth: checkpoint path, the path to save your model while training
- lossfn: loss function, you have two loss functions bboxloss and iouloss, it is best to use bboxloss because iouloss is broken (if you can find a creative way to fix, great! please ping me on asceznyk@gmail.com
- patience: this is the number of epochs to wait on stagnation of validation loss in order to stop training, the default value is 10 but you can change it to whatever you like
$ python detect.py --testdir test --names yournames.labels --cfg yolov3custom.cfg --weights pathtochekpt.pth --savedir outputs --boxdir gtruths
- testdir: path to the directory with all the test images ONLY
- names: path to the .names file
- cfg: path to model configuration file (use the yolov3custom.cfg from the first step)
- weights: checkpoint path, the same checkpoint path from the previous step
- savedir: path to directory to save all the predictions of the model
- boxdir (optional): path to directory to save all the actual images wit ground truth boxes