To reproduce article results you need to use this data:
test_cls.py - the file for testing classifier
train_cls.py - the file for training neural network
Install all required libraries
$ pip install -r requrements_cls.txt
If you want to reproduce the results on "tigers_vs_leopards" dataset you need to specify path to config.yaml file that is located in configs/config.yaml. In this case, the weights that are trained on 29 classes will be used.
$ python train_cls.py -c configs/config.yaml
You can change some parameters like number of epochs, batch_size, input_size ant etc. The path to training and validation data is specified by default. If you want to use another dataset you should change train_dir, val_dir params.
$ python train_cls.py -c configs/config.yaml --epochs 10 --own_weights paht/to/your/weights --batch_size 32 --input_size 256 --loss smooth --train_dir path/to/your/train/data --val_dir path/to/your/val/data
When the network training is completed, directory results_train will be created, which will contain the following files:
- config.yaml - the configuration file with training params
- mapping.yaml - the file with classes on which the classifier was trained
- .pt - the weights of neural network
- results_.json - the results of training with losses and accuracy
- learning_curve.png - the curves of training and validation
- events.out.tfevents... - the results for tensorboard
If you want to evaluate the performance of a neural network on test data, you need to specify the path to the directory with the weights and test data
$ python test_cls.py --pt_w weights/Classification/tigers_vs_leopards/resnest101e --pt_data data/Classificationtigers_vs_leopards/test
or you can use your trained weights:
$ python test_cls.py --pt_w path/to/your/weights --pt_data data/Classification/tigers_vs_leopards/test
After testing, directory results_test will be created where the confusion matrix will be stored.
- You need to clone git repository with YOLOv5
$ git clone https://github.com/ultralytics/yolov5.git
- Then you need to install all libraries using requirements.txt for yolov5
$ pip install -r requirements.txt
-
Download dataset and change path to train and val dataset in
animals.yaml file
-
After that, you need to train YOLOv5 using our pretrained weights
$ python train.py --imgsz 1280 --epochs 10 --data data/Detection/tigers_vs_leopards/animals.yaml --weights weights/Detection/YOLOv5_L6/weights/best.pt --single-cls --batch 2
- To evaluate trained network on the test dataset you need to use val.py file in YOLOv5 repository
$ python val.py --test --imgsz 1280 --data data/Detection/tigers_vs_leopards/animals.yaml --weights weights/Detection/YOLOv5_L6/weights/best.pt --single-cls --batch 24 --single-cls