Skip to content

jyPark1105/Thermal-Project

Repository files navigation

YOLOv7 for EN675

This is a code modified to work with EN675 by taking the code from https://github.com/WongKinYiu/yolov7.

Implementation of paper - YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors

Installation

  • python3.8
# create the docker container, you can change the share memory size if you have more.
pip install -r requirement.txt

# install torch, cuda
...

Testing

  • resolution : 512x896 (HxW)

  • dataset : COCO 2017 VAL

  • GPU mAP

 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.369
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.548
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.399
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.213
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.410
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.491
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.307
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.524
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.580
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.411
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.628
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.723
  • NPU mAP - this test on board
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.291
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.482
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.313
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.139
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.321
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.398
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.239
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.365
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.381
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.196
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.419
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.501

To measure accuracy, download COCO-annotations for Pycocotools to the ./coco/annotations/instances_val2017.json

Training

Data preparation

bash scripts/get_coco.sh
  • Download MS COCO dataset images (train, val, test) and labels. If you have previously used a different version of YOLO, we strongly recommend that you delete train2017.cache and val2017.cache files, and redownload labels

Single GPU training

CUDA_VISIBLE_DEVICES=0 python train.py --batch-size 32 --data data/example.yaml --img-size-train 640 640 --img-size-test 640 640 --cfg cfg/yolov7-tiny-silu-en675-rfb.yaml --weights yolov7-tiny.pt --hyp data/hyp.scratch.tiny.yaml

Multiple GPU training

python -m torch.distributed.launch --nproc_per_node 3 train.py --workers 8 --device 0,1,2 --sync-bn --batch-size 120 --data data/example.yaml --img-size-train 640 640 --img-size-test 640 640 --cfg cfg/yolov7-tiny-silu-en675-rfb.yaml --weights yolov7-tiny.pt --hyp data/hyp.scratch.tiny.yaml

Inference

On video:

python detect.py --weights {pt file} --conf 0.25 --img-size 640 640 --source {video file path}

On image:

python detect.py --weights {pt file} --conf 0.25 --img-size 640 640 --source {imgae file path}

Testing

CUDA_VISIBLE_DEVICES=0 python test.py --data data/example.yaml --img 640 640 --batch-size 32 --conf 0.001 --iou 0.65 --weights {pt file} 

Export to ONNX

  • img-size {height, width}
python export.py --weight {pt file} --img-size 640 640 --simplify --batch-size 1

Citation

@article{wang2022yolov7,
  title={{YOLOv7}: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors},
  author={Wang, Chien-Yao and Bochkovskiy, Alexey and Liao, Hong-Yuan Mark},
  journal={arXiv preprint arXiv:2207.02696},
  year={2022}
}

Acknowledgements

Expand

About

Thermal Project in AI & Big-Data Lecture

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published