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

YOLOv7 trains extra modules that boost real-time detector accuracy at no inference cost

Chien-Yao Wang, Alexey Bochkovskiy, Hong-Yuan Mark Liao · arXiv · 2022-7-6

- **Problem** Real-time detector gains have mostly come from tuning architectures for one hardware target, so they stay tied to one class of device. Changes to how the detector is trained have received less attention.
- **Method** YOLOv7 adds training-only modules and label rules instead of changing the architecture alone. Extra structure is folded away before deployment, so inference cost stays the same.
- **Results** YOLOv7 reaches 56.8% AP among real-time detectors at 30 FPS or higher on V100. YOLOv7-E6 scores 55.9% AP at 56 FPS, compared with 53.9% AP for SWIN-L Cascade-Mask R-CNN.

## Why training-side changes matter for real-time detectors

Real-time detection has to run on very different hardware, from mobile CPUs and NPUs to cloud GPUs. Much of the recent work tunes the architecture for one target, such as MobileNet, ShuffleNet or GhostNet designs for CPUs, and ResNet, DarkNet or DLA backbones with CSPNet for GPUs. So most of the gains are tied to one class of device.

The authors take a different route and change how the detector is trained, not only what runs at inference. They call these changes trainable bag-of-freebies, meaning modules and optimization methods that add training cost to raise accuracy while adding no inference cost. Dynamic label assignment raises new questions once a model has several output layers.

The first question is which re-parameterized module can replace which original module, and the second is how dynamic targets should be assigned to the different output branches.

## Where the changes sit in the detector

The idea is to add training-time structure and better targets, then fold or drop that structure before the detector is deployed. The changes fall into four groups: the E-ELAN block, the compound scaling rule for concatenation models, planned re-parameterized convolution, and lead-guided label assignment for two heads. These parts are combined into named variants for edge GPU, normal GPU and cloud GPU, including YOLOv7-tiny, YOLOv7, YOLOv7-W6, and scaled versions such as YOLOv7-X, YOLOv7-E6, YOLOv7-D6 and YOLOv7-E6E.

The other freebies are smaller: batch normalization is merged into the convolution at inference, implicit knowledge from YOLOR is reduced to a vector, and an EMA model is used as the final model.

## E-ELAN and compound scaling for concatenation models

E-ELAN leaves the gradient path of ELAN as it was and changes only the computational blocks. Each block uses group convolution to expand channels and cardinality, and the feature maps of its groups are shuffled into g groups and concatenated. The g groups are then added together, so each group has the channel count of the original block and the transition layer is unchanged.

The authors argue that this lets different groups of blocks learn more diverse features.

Scaling becomes coupled in concatenation models, because a change in depth also changes the input width of the transition layer that follows. Depth and width therefore can't be scaled independently, so the depth change of a computational block has to be paired with a matching width change in the transition layers. Compound scaling is 0.5 AP points above width-only with fewer parameters and less computation, and 0.2 AP points above depth-only with 2.9% more parameters and 1.2% more computation.

The authors read this as evidence that scaling depth and width together uses parameters and computation more efficiently.

## Planned re-parameterized convolution

During training, RepConv combines a 3 × 3 convolution, a 1 × 1 convolution and an identity connection in one layer, and at inference these merge into a single convolution. The authors found that RepConv worked well on VGG, but when applied to ResNet and DenseNet its accuracy dropped noticeably. They attribute this to the identity connection breaking the residual path in ResNet and the concatenation in DenseNet, which removes gradient diversity across feature maps.

Their fix is RepConvN, the same structure without the identity connection, used wherever a layer has a residual or concatenation connection.

To test the design on a concatenation model, the authors placed RepConv at different 3 × 3 convolution positions in a 3-stacked ELAN. The base scored 52.26% AP val, and the five placements ranged from 52.17% to 52.33%. Placements (b) and (c) sit above the base, while (a), (d) and (e) sit below it, so the placement matters but only by small margins.

For residual models, the original dark block has no 3 × 3 convolution, so the authors built a reversed dark block with the 1 × 1 and 3 × 3 positions swapped. Both versions have the same parameter count and operations, so the authors treat the comparison as fair. RepRCSP scored 54.85% compared to 54.82% for the YOLOR-W6 base, and 50.91% compared to 50.81% for the YOLOR-CSP base.

Not every variant helps, since RepCSP fell to 54.67% on YOLOR-W6, so the design supports keeping the chosen variant rather than any re-parameterization.

## Lead-guided label assignment for two heads

Deep supervision adds an auxiliary head in middle layers so that shallower layers receive an extra loss, while only the lead head produces the final output. Detectors often build soft labels from network predictions together with the ground truth, so the open question is which targets the auxiliary head should receive. The common practice is to assign labels to each head separately, from that head's own predictions.

The authors propose using the lead head's prediction together with the ground truth to produce soft labels for both heads. The reasoning is that the lead head learns more strongly, so its soft labels describe the data better, and the auxiliary head can absorb what the lead has already learned. This leaves the lead head free to focus on residual information it hasn't learned yet.

The coarse-to-fine variant builds two label sets: a fine set identical to the lead-guided one, and a coarse set that makes more grid cells positive by relaxing the positive assignment rule. To keep the extra coarse positives from dominating, the decoder restricts them so they can't produce soft labels perfectly, and the upper bound of objectness is constrained by the distance from the object center.

On YOLOv7-E6 at 1280 input, the base scored 55.6% AP val, independent assignment 55.8%, lead guided assignment 55.9%, and coarse-to-fine lead guided assignment 55.9%. The text calls the coarse-to-fine variant best in all cases, but its AP margin over lead guided assignment is zero. Adding the upper-bound constraint leaves AP val at 55.9% and moves AP75 from 61.0% to 61.1%.

The partial auxiliary head connects the auxiliary head after one set of feature maps before cardinality merging, so the assistant loss doesn't update those new feature maps directly. On YOLOv7-E6E at 1280 input, the base scored 56.3% AP val, the full auxiliary head 56.5%, and the partial auxiliary head 56.8%. The partial variant's gain of about half an AP point over the base is the largest single change in this group of ablations.

The objectness maps in Figure 8 are a qualitative check, and the authors read them as showing the lead head taking in residual information from the shared targets.

## Results against earlier YOLO versions and other detectors

The baselines are YOLOv4 and YOLOR-CSP, trained with the same settings as YOLOv7. The accuracy gain is small, but the model is also smaller and needs less computation. On tiny models, YOLOv7-tiny scored 35.2% AP val at 416 input, compared to 24.9% for YOLOv4-tiny. At 320 input, YOLOv7-tiny and YOLOv4-tiny-3l both score 30.8%, with YOLOv7-tiny using 3.5G FLOPs compared to 5.2G.

In the real-time table, YOLOv7 scored 51.4% AP test at 161 FPS, compared to 78 FPS for PPYOLOE-L at the same accuracy. These inference speeds are the authors' own estimates, using letterbox resizing of the input to a long side of 640 or 1280.

The authors' headline claim is 56.8% AP among real-time detectors with 30 FPS or higher on V100. YOLOv7-E6 ran at 56 FPS on V100 with 55.9% AP, compared to 9.2 FPS and 53.9% AP for SWIN-L Cascade-Mask R-CNN. The transformer and ConvNeXt rows were timed on A100 while the YOLOv7 rows were timed on V100, so those speed ratios cross hardware.

The paper's one matched-condition comparison with YOLOv6 is run on V100 with batch 32. YOLOv7-tiny scored 35.2% AP at 0.4 ms, compared to 35.0% AP at 0.5 ms for YOLOv6-n. The margin is small, so the evidence here is mainly speed at similar accuracy.

## Limitations

All models are trained from scratch on MS COCO, without pre-trained weights or other datasets. The authors deliberately leave out self-supervised learning and knowledge distillation, which need extra data or a large model. Other datasets were not tested, so the results don't show how these freebies transfer.

The residual-model re-parameterization results move the YOLOR baselines by fractions of a point.

AP also moves with evaluation settings: YOLOv7-X scored 52.9% with FP16 at IoU threshold 0.65, and 53.1% with FP32 at 0.70. The text gives a 75% parameter reduction against YOLOv4, but Table 1 lists 64.4M and 36.9M, so the raw counts are the safer figures to quote. FLOPs use rectangle input sizes and inference times use letterbox resizing, both set by the authors.

## Paper info

- **Authors**: Chien-Yao Wang, Alexey Bochkovskiy, Hong-Yuan Mark Liao
- **Venue**: arXiv · Preprint
- **First published**: 2022-7-6
- **Added**: 2026-11-11
- **Updated**: 2022-7-6
- **Version**: v1
- **arXiv**: 2207.02696
- **Category**: cs.CV
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/2207.02696v1) · [PDF ↗](https://arxiv.org/pdf/2207.02696v1)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Chien-Yao Wang, Alexey Bochkovskiy, Hong-Yuan Mark Liao (2022). YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors. arXiv:2207.02696v1. https://arxiv.org/abs/2207.02696v1

**BibTeX**

```
@misc{wang2022yolov7,
  title = {{YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors}},
  author = {Chien-Yao Wang and Alexey Bochkovskiy and Hong-Yuan Mark Liao},
  year = {2022},
  eprint = {2207.02696},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2207.02696v1}
}
```

## Related papers

- [YOLOv4: Optimal Speed and Accuracy of Object Detection](https://refivu.com/en/papers/3320d624-7e40-4d1e-b251-49a39602a21c-yolov4-optimal-speed-and-accuracy-of-object-detection.md)
- [ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design](https://refivu.com/en/papers/d1e3c93e-79dc-4e3d-a949-2f726da0b409-shufflenet-v2-practical-guidelines-for-efficient-cnn.md)
- [PCT: Point cloud transformer](https://refivu.com/en/papers/54b01448-d153-4635-92bf-22ab3866d1ae-pct-point-cloud-transformer.md)
- [YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information](https://refivu.com/en/papers/11ec3a37-5335-4563-b8f6-6949e50f3a4f-yolov9-learning-what-you-want-to-learn-using.md)
- [Concealed Object Detection](https://refivu.com/en/papers/6a17f952-9bf8-4221-9f67-00c90ed3fa01-concealed-object-detection.md)
- [Deep Laplacian Pyramid Networks for Fast and Accurate Super-Resolution](https://refivu.com/en/papers/640b6f7c-566c-4cc7-a351-edc07a5183c8-deep-laplacian-pyramid-networks-for-fast-and-accurate.md)

## Other paper commentary

- [A Survey on Deep Learning in Medical Image Analysis](https://refivu.com/en/papers/4d173b56-9ea6-4644-98f2-af1794e63965-a-survey-on-deep-learning-in-medical-image.md)
- [The Unreasonable Effectiveness of Deep Features as a Perceptual Metric](https://refivu.com/en/papers/7a2a39ad-a72d-46f5-b96c-8392e55b66ee-the-unreasonable-effectiveness-of-deep-features-as-a.md)
- [Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation](https://refivu.com/en/papers/c3292ceb-d0f0-4799-82a9-423146b8a1ba-encoder-decoder-with-atrous-separable-convolution-for.md)
- [SegNet: A Deep Convolutional Encoder-Decoder Architecture for Image Segmentation](https://refivu.com/en/papers/6ef91be9-1378-47a3-b7a6-b70c7cdb6ba6-segnet-a-deep-convolutional-encoder-decoder-architecture-for.md)
- [MobileNetV2: Inverted Residuals and Linear Bottlenecks](https://refivu.com/en/papers/db077330-ba7d-43fd-b0bb-608efe9dd258-mobilenetv2-inverted-residuals-and-linear-bottlenecks.md)
- [Communication-Efficient Learning of Deep Networks from Decentralized Data](https://refivu.com/en/papers/67777aca-9be4-4537-8568-875c944fceee-communication-efficient-learning-of-deep-networks-from.md)
- [Empirical Evaluation of Gated Recurrent Neural Networks on Sequence Modeling](https://refivu.com/en/papers/136a3b1f-3eb6-469b-8a8a-7536056851d5-empirical-evaluation-of-gated-recurrent-neural-networks-on.md)
- [Convolutional Neural Networks for Sentence Classification](https://refivu.com/en/papers/e03eeb97-8544-4ef6-a8e6-47276e072373-convolutional-neural-networks-for-sentence-classification.md)
- [Qwen3 Technical Report](https://refivu.com/en/papers/efd0e142-cc80-4bf8-b7fa-33c525cf374d-qwen3-technical-report.md)
- [Explaining and Harnessing Adversarial Examples](https://refivu.com/en/papers/37bc09da-a299-4ed8-8384-7f87f7409fd4-explaining-and-harnessing-adversarial-examples.md)

## Terms in this paper

- [AP](https://refivu.com/en/terms/476f7c8deadf-ap)
- [FLOPs](https://refivu.com/en/terms/14c405888d5b-flops)
- [FPS](https://refivu.com/en/terms/e6b895af6e27-fps)
- [deep supervision](https://refivu.com/en/terms/5fe4f2985157-deep-supervision)
- [Microsoft COCO dataset](https://refivu.com/en/terms/316d96f943a2-microsoft-coco-dataset)
- [Compound scaling](https://refivu.com/en/terms/717e2185385e-compound-scaling)
- [ELAN](https://refivu.com/en/terms/73161fefec46-elan)
- [model scaling](https://refivu.com/en/terms/8183f72b0f80-model-scaling)
- [real-time object detection](https://refivu.com/en/terms/d506775074a5-real-time-object-detection)
- [RepConv](https://refivu.com/en/terms/9c17eebf17fb-repconv)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/c2cb4858-244f-407a-916b-4d41a9df7d4f-yolov7-trainable-bag-of-freebies-sets-new-state)
