Skip to content

Implementation of paper "ECF-YOLOv7-tiny: Improving feature fusion and the receptive field for lightweight object detectors"

License

Notifications You must be signed in to change notification settings

dbacea/ecf-yolov7-tiny

Repository files navigation

Official ECF-YOLOv7-tiny

Implementation of paper - ECF-YOLOv7-tiny: Improving feature fusion and the receptive field for lightweight object detectors

Performance

MS COCO

Model Test Size APval AP50val AP75val batch 32 fps on Jetson Nano
YOLOv7-tiny 416 35.2% 52.8% 37.3% 14.4 fps
SE-YOLOv7-tiny 416 34.8% 52.5% 36.6% 13.8 fps
YOLOv9-t 416 32.2% 46.5% 34.2% 7.1 fps
YOLOv10-n 416 32.6% 47.2% 35.0% 14 fps
YOLOv11-n 416 32.5% 46.8% 34.7% 18 fps
YOLOv12-n 416 33.3% 48.2% 35.4% 12 fps
ECF-YOLOv7-tiny 416 38.2% 56.3% 40.7% 8.8 fps
ECF-YOLOv7-tiny-s 416 37.8% 56.0% 40.0% 9.3 fps

Installation

Docker environment (recommended)

Expand
# create the docker container, you can change the share memory size if you have more.
nvidia-docker run --name ecf-yolov7-tiny -it -v your_coco_path/:/coco/ -v your_code_path/:/ecf-yolov7 --shm-size=64g nvcr.io/nvidia/pytorch:21.08-py3

# apt install required packages
apt update
apt install -y zip htop screen libgl1-mesa-glx

# pip install required packages
pip install seaborn thop

# go to code folder
cd /ecf-yolov7-tiny

Testing

#test ecf-yolov7-tiny
python test.py --data data/coco.yaml --img 416 --batch 32 --conf 0.001 --iou 0.65 --device 0 --weights weights/ecf-yolov7-tiny.pt --name ecf-yolov7-tiny_416_val

#test ecf-yolov7-tiny-s
python test.py --data data/coco.yaml --img 416 --batch 32 --conf 0.001 --iou 0.65 --device 0 --weights weights/ecf-yolov7-tiny-s.pt --name ecf-yolov7-tiny-s_416_val

You will get the results:

 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.378
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.560
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.400
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.182
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.418
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.554
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.315
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.513
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.556
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.333
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.616
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.750

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

# train ecf-yolov7-tiny
python train.py --workers 8 --device 0 --batch-size 32 --epochs 500 --data data/coco.yaml --img 416 416 --cfg cfg/training/ecf-yolov7-tiny.yaml --weights '' --name ecf-yolov7-tiny --hyp data/hyp.scratch.tiny.yaml

# train ecf-yolov7-tiny-s
python train.py --workers 8 --device 0 --batch-size 32 --epochs 500 --data data/coco.yaml --img 416 416 --cfg cfg/training/ecf-yolov7-tiny-s.yaml --weights '' --name ecf-yolov7-tiny-s --hyp data/hyp.scratch.tiny.yaml

Multiple GPU training

# train ecf-yolov7-tiny
python -m torch.distributed.launch --nproc_per_node 2 --master_port 9527 train.py --workers 16 --device 0,1 --sync-bn --batch-size 32 --epochs 500 --data data/coco.yaml --img 416 416 --cfg cfg/training/ecf-yolov7-tiny.yaml --weights '' --name ecf-yolov7-tiny --hyp data/hyp.scratch.tiny.yaml

# train ecf-yolov7-tiny-s
python -m torch.distributed.launch --nproc_per_node 2 --master_port 9527 train.py --workers 16 --device 0,1 --sync-bn --batch-size 32 --epochs 500 --data data/coco.yaml --img 416 416 --cfg cfg/training/ecf-yolov7-tiny-s.yaml --weights '' --name ecf-yolov7-tiny-s --hyp data/hyp.scratch.tiny.yaml

Inference

On video:

python detect.py --weights weights/ecf-yolov7-tiny-s.pt --conf 0.25 --img-size 416 --source yourvideo.mp4

On image:

python detect.py --weights weights/ecf-yolov7-tiny-s.pt --conf 0.25 --img-size 416 --source inference/images/horses.jpg

Check BFLOPs

pip install thop
python detect_flops.py --weights weights/ecf-yolov7-tiny-s.pt --img-size 416 --conf 0.25 --source inference/images/horses.jpg

Check speed

python test.py --task speed --data data/coco.yaml --img 416 --batch 32 --conf 0.001 --iou 0.65 --device 0 --weights weights/ecf-yolov7-tiny-s.pt --name ecf-yolov7-tiny-s_416_b32_val_500ep

Tested with: Python 3.7.13, Pytorch 1.11.0+cu116

Citation

@inproceedings{bacea2025ecf,
  title={ECF-YOLOv7-Tiny: Improving Feature Fusion and the Receptive Field for Lightweight Object Detectors},
  author={Bacea, Dan-Sebastian and Oniga, Florin},
  booktitle={2025 IEEE/CVF Winter Conference on Applications of Computer Vision (WACV)},
  pages={1577--1586},
  year={2025},
  organization={IEEE}
}

Acknowledgements

Expand

About

Implementation of paper "ECF-YOLOv7-tiny: Improving feature fusion and the receptive field for lightweight object detectors"

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages