← 开源
Atten4Vis

LW-DETR

This repository is an official implementation of the paper "LW-DETR: A Transformer Replacement to YOLO for Real-Time Detection".

ModelsVision modelsPython
在 GitHub 打开
增长势头
+024 小时新增 Star0.0%
514
Star
47
Fork
+0
本周
2
贡献者
创建于 2024-05-28 · 更新于 2026-10-01 · 今日第 17980 名
主要开发者
xbsuattn4det

Atten4Vis/LW-DETR 排名第 17,980,有 514 个星标。

同类别比较

Atten4Vis/LW-DETR 排名第 17,980,此处有 8 个同类条目;baidu/ERNIE-Image 排名第 17,994。

同类别比较
名称排名指标
acids-ircam/ddsp_pytorch17,922
语言:
C
星标数:
517
分叉数:
62
简介:
Implementation of Differentiable Digital Signal Processing (DDSP) in Pytorch
zhuyu-cs/MeanFlow17,938
语言:
Python
星标数:
517
分叉数:
38
简介:
Pytorch implementation of MeanFlow on ImageNet and CIFAR10
MAGICS-LAB/DNABERT_217,942
语言:
Shell
星标数:
516
分叉数:
103
简介:
[ICLR 2024] DNABERT-2: Efficient Foundation Model and Benchmark for Multi-Species Genome
KangLiao929/Puffin17,962
语言:
Python
星标数:
515
分叉数:
23
简介:
Puffin Series: Towards Unified Multimodal 3D World Models
baidu/ERNIE-Image17,994
语言:
Python
星标数:
514
分叉数:
37
简介:
ERNIE-Image is an open text-to-image generation model developed by the ERNIE-Image team at Baidu. It is built on a single-stream Diffusion Transformer (DiT), with only 8B DiT parameters, it reaches state-of-the-art performance among open-weight text-to-image models.
facebookresearch/AudioDec17,998
语言:
Python
星标数:
514
分叉数:
33
简介:
An Open-source Streaming High-fidelity Neural Audio Codec
shansongliu/MuMu-LLaMA18,005
语言:
Jupyter Notebook
星标数:
514
分叉数:
42
简介:
This is the official repository for M2UGen
RetroCirce/HTS-Audio-Transformer18,038
语言:
Python
星标数:
512
分叉数:
76
简介:
The official code repo of "HTS-AT: A Hierarchical Token-Semantic Audio Transformer for Sound Classification and Detection"
关键参数与规格
关键参数与规格
参数值
语言Python
类别Models
子类别Vision models
关键词Inference optimization, Model architecture, Object detection
星标数514
分叉数47
贡献者2
创建日期2024-05-28
更新日期2026-10-01
1 天星标数0
7 天星标数0
排名17,980
上次排名17,753
排名变化-227
7 天星标排名16,398
上次 7 天星标排名16,410
7 天星标排名变化12
总星标排名18,947
上次总星标排名18,919
总星标排名变化-28
README 摘录

LW-DETR: A Transformer Replacement to YOLO for Real-Time Detection This is the *official* repository with PyTorch implementation of LW-DETR: A Transformer Replacement to YOLO for Real-Time Detection. ☀️ If you find this work useful for your research, please kindly star our repo and cite our paper! ☀️ Highlights Release a series of real-time detection models in LW-DETR, including LW-DETR-tiny, LW-DETR-small, LW-DETR-medium, LW-DETR-large and LW-DETR-xlarge, named . Please

refer to Hugging Face to download. Release a series of pretrained models in LW-DETR. Please refer to Hugging Face to download. News [🔥2025/02/18] We release a demo script to test LW-DETR. [2024/07/15] We present OVLW-DETR, an efficient open-vocabulary detector with outstanding performance and low latency, built upon LW-DETR. It surpasses existing real-time open-vocabulary detectors on the standard Zero-Shot LVIS benchmark. The source code and pre-trained model is

comming soon, please stay tuned! Inference Demo with Pre-trained Model 5. Introduction LW-DETR is a light-weight detection tranformer, which outperforms YOLOs for real-time object detection. The architecture is a simple stack of a ViT encoder, a projector, and a shallow DETR decoder. LW-DETR leverages recent advanced techniques, such as training-effective techniques, e. , improved loss and pretraining, and interleaved window and global attentions for reducing the ViT encoder complexity. LW-DETR improves the ViT encoder

by aggregating multi-level feature maps, and the intermediate and final feature maps in the ViT encoder, forming richer feature maps, and introduces window-major feature map organization for improving the efficiency of interleaved attention computation. LW-DETR achieves superior performance than on existing real-time detectors, e. , YOLO and its variants, on COCO and other benchmark datasets. Installation Requirements The code is developed and validated under . Higher versions might be available as well. Create your own Python environment with

Anaconda. For training and evaluation: For deployment: Please refer to NVIDIA for installation instruction of TensorRT 5. Preparation Data preparation For **MS COCO** dataset, please download and extract COCO 2017 train and val images with annotations from We expect the directory structure to be the following: For **Objects365** dataset for pretraining, please download Objects365 images with annotations from Model preparation All the checkpoints can be found in Hugging Face. We pretrain the ViT on the dataset Objects365 using a MIM

method, CAE v2, based on the pretrained models. Please refer to the following link to download the pretrained models, and put them into . We retrain the encoder and train the projector and the decoder on Objects365 in a supervision manner. Please refer to the following link to download the pretrained models, and put them into . We finetune the pretrained model on COCO. If you want to reimplement our repo, please skip this step. If you want to directly evaluate our

trained models, please refer to the following link to download the finetuned models, and put them into . Inference Demo with

常见问题

记录了多少星标和分叉?

Atten4Vis/LW-DETR 有 514 个星标和 47 个分叉。

仓库排名是多少?

Atten4Vis/LW-DETR 排名第 17,980。

记录的语言和类别是什么?

Atten4Vis/LW-DETR 有 514 个星标,语言为 Python,类别为 Models。

哪个仓库排名最接近?

Atten4Vis/LW-DETR 与 baidu/ERNIE-Image 比较,后者排名第 17,994,有 514 个星标。

README

LW-DETR: A Transformer Replacement to YOLO for Real-Time Detection

This is the official repository with PyTorch implementation of LW-DETR: A Transformer Replacement to YOLO for Real-Time Detection.

☀️ If you find this work useful for your research, please kindly star our repo and cite our paper! ☀️

Highlights

  • Release a series of real-time detection models in LW-DETR, including LW-DETR-tiny, LW-DETR-small, LW-DETR-medium, LW-DETR-large and LW-DETR-xlarge, named . Please refer to Hugging Face to download.
  • Release a series of pretrained models in LW-DETR. Please refer to Hugging Face to download.

News

[🔥2025/02/18] We release a demo script to test LW-DETR. Please refer to Section 4.

[2024/07/15] We present OVLW-DETR, an efficient open-vocabulary detector with outstanding performance and low latency, built upon LW-DETR. It surpasses existing real-time open-vocabulary detectors on the standard Zero-Shot LVIS benchmark. The source code and pre-trained model is comming soon, please stay tuned!

Catalogue

1. Introduction

LW-DETR is a light-weight detection tranformer, which outperforms YOLOs for real-time object detection. The architecture is a simple stack of a ViT encoder, a projector, and a shallow DETR decoder. LW-DETR leverages recent advanced techniques, such as training-effective techniques, e.g., improved loss and pretraining, and interleaved window and global attentions for reducing the ViT encoder complexity. LW-DETR improves the ViT encoder by aggregating multi-level feature maps, and the intermediate and final feature maps in the ViT encoder, forming richer feature maps, and introduces window-major feature map organization for improving the efficiency of interleaved attention computation. LW-DETR achieves superior performance than on existing real-time detectors, e.g., YOLO and its variants, on COCO and other benchmark datasets.

2. Installation

Requirements

The code is developed and validated under python=3.8.19, pytorch=1.13.0, cuda=11.6,TensorRT-8.6.1.6. Higher versions might be available as well.

  1. Create your own Python environment with Anaconda.
conda create -n lwdetr python=3.8.19
conda activate lwdetr
  1. Clone this repo.
git clone https://github.com/Atten4Vis/LW-DETR.git
cd LW-DETR
  1. Install PyTorch and torchvision.

Follow the instruction on https://pytorch.org/get-started/locally/.

# an example:
conda install pytorch==1.13.0 torchvision==0.14.0 pytorch-cuda=11.6 -c pytorch -c nvidia
  1. Install required packages.

For training and evaluation:

pip install -r requirements.txt

For deployment:

Please refer to NVIDIA for installation instruction of TensorRT

pip install -r deploy/requirements.txt
  1. Compiling CUDA operators
cd models/ops
python setup.py build install
# unit test (should see all checking is True)
python test.py
cd ../..

3. Preparation

Data preparation

For MS COCO dataset, please download and extract COCO 2017 train and val images with annotations from http://cocodataset.org. We expect the directory structure to be the following:

COCODIR/
  ├── train2017/
  ├── val2017/
  └── annotations/
  	├── instances_train2017.json
  	└── instances_val2017.json

For Objects365 dataset for pretraining, please download Objects365 images with annotations from https://www.objects365.org/overview.html.

Model preparation

All the checkpoints can be found in Hugging Face.

  1. Pretraining on Objects365.
  • Pretrained the ViT.

We pretrain the ViT on the dataset Objects365 using a MIM method, CAE v2, based on the pretrained models. Please refer to the following link to download the pretrained models, and put them into pretrain_weights/.

Model Comment
caev2_tiny_300e_objects365 pretrained ViT model on objects365 for LW-DETR-tiny/small using CAE v2
caev2_tiny_300e_objects365 pretrained ViT model on objects365 for LW-DETR-medium/large using CAE v2
caev2_tiny_300e_objects365 pretrained ViT model on objects365 for LW-DETR-xlarge using CAE v2
  • Pretrained LW-DETR.

We retrain the encoder and train the projector and the decoder on Objects365 in a supervision manner. Please refer to the following link to download the pretrained models, and put them into pretrain_weights/.

Model Comment
LWDETR_tiny_30e_objects365 pretrained LW-DETR-tiny model on objects365
LWDETR_small_30e_objects365 pretrained LW-DETR-small model on objects365
LWDETR_medium_30e_objects365 pretrained LW-DETR-medium model on objects365
LWDETR_large_30e_objects365 pretrained LW-DETR-large model on objects365
LWDETR_xlarge_30e_objects365 pretrained LW-DETR-xlarge model on objects365
  1. Finetuning on COCO. We finetune the pretrained model on COCO. If you want to reimplement our repo, please skip this step. If you want to directly evaluate our trained models, please refer to the following link to download the finetuned models, and put them into output/.
Model Comment
LWDETR_tiny_60e_coco finetuned LW-DETR-tiny model on COCO
LWDETR_small_60e_coco finetuned LW-DETR-small model on COCO
LWDETR_medium_60e_coco finetuned LW-DETR-medium model on COCO
LWDETR_large_60e_coco finetuned LW-DETR-large model on COCO
LWDETR_xlarge_60e_coco finetuned LW-DETR-xlarge model on COCO

4. Inference Demo with Pre-trained Model

We’ve provided demo for visualizing the customized input images using pretrained weights.

For visualizing demos:

  1. Pick a model and its config from projects, for example, LWDETR_small_60e_coco.
  2. Download the pretrained weights from the link on the page above.
  3. Using the provided demo.py to demo the input images. Run it as:
  sh demo/lwdetr_small_coco_infer.sh output/LWDETR_small_60e_coco.pth demo/000000496954.jpg output

5. Train

You can directly run scripts/lwdetr__coco_train.sh file for the training process on coco dataset.

Train a LW-DETR-tiny model

sh scripts/lwdetr_tiny_coco_train.sh /path/to/your/COCODIR

Train a LW-DETR-small model

sh scripts/lwdetr_small_coco_train.sh /path/to/your/COCODIR

Train a LW-DETR-medium model

sh scripts/lwdetr_medium_coco_train.sh /path/to/your/COCODIR

Train a LW-DETR-large model

sh scripts/lwdetr_large_coco_train.sh /path/to/your/COCODIR

Train a LW-DETR-xlarge model

sh scripts/lwdetr_xlarge_coco_train.sh /path/to/your/COCODIR

6. Eval

You can directly run scripts/lwdetr__coco_eval.sh file for the evaluation process on coco dataset. Please refer to 3. Preparation to download a series of LW-DETR models.

Eval our pretrained LW-DETR-tiny model

sh scripts/lwdetr_tiny_coco_eval.sh /path/to/your/COCODIR /path/to/your/checkpoint

Eval our pretrained LW-DETR-small model

sh scripts/lwdetr_small_coco_eval.sh /path/to/your/COCODIR /path/to/your/checkpoint

Eval our pretrained LW-DETR-medium model

sh scripts/lwdetr_medium_coco_eval.sh /path/to/your/COCODIR /path/to/your/checkpoint

Eval our pretrained LW-DETR-large model

sh scripts/lwdetr_large_coco_eval.sh /path/to/your/COCODIR /path/to/your/checkpoint

Eval our pretrained LW-DETR-xlarge model

sh scripts/lwdetr_xlarge_coco_eval.sh /path/to/your/COCODIR /path/to/your/checkpoint

7. Deploy

Export models

You can run scripts/lwdetr__coco_export.sh file to export models for development. Before execution, please ensure that TensorRT and cuDNN environment variables are correctly set.

Export a LW-DETR-tiny model

# export ONNX model
sh scripts/lwdetr_tiny_coco_export.sh /path/to/your/COCODIR /path/to/your/checkpoint
# convert model from ONNX to TensorRT engine as well
sh scripts/lwdetr_tiny_coco_export.sh /path/to/your/COCODIR /path/to/your/checkpoint --trt

Export a LW-DETR-small model

# export ONNX model
sh scripts/lwdetr_small_coco_export.sh /path/to/your/COCODIR /path/to/your/checkpoint
# convert model from ONNX to TensorRT engine as well
sh scripts/lwdetr_small_coco_export.sh /path/to/your/COCODIR /path/to/your/checkpoint --trt

Export a LW-DETR-medium model

# export ONNX model
sh scripts/lwdetr_medium_coco_export.sh /path/to/your/COCODIR /path/to/your/checkpoint
# convert model from ONNX to TensorRT engine as well
sh scripts/lwdetr_medium_coco_export.sh /path/to/your/COCODIR /path/to/your/checkpoint --trt

Export a LW-DETR-large model

# export ONNX model
sh scripts/lwdetr_large_coco_export.sh /path/to/your/COCODIR /path/to/your/checkpoint
# convert model from ONNX to TensorRT engine as well
sh scripts/lwdetr_large_coco_export.sh /path/to/your/COCODIR /path/to/your/checkpoint --trt

Export a LW-DETR-xlarge model

# export ONNX model
sh scripts/lwdetr_xlarge_coco_export.sh /path/to/your/COCODIR /path/to/your/checkpoint
# convert model from ONNX to TensorRT engine as well
sh scripts/lwdetr_xlarge_coco_export.sh /path/to/your/COCODIR /path/to/your/checkpoint --trt

Run benchmark

You can use deploy/benchmark.py tool to run benchmarks of inference latency.

# evaluate and benchmark the latency on a onnx model
python deploy/benchmark.py --path=/path/to/your/onnxmodel --coco_path=/path/to/your/COCODIR --run_benchmark 
# evaluate and benchmark the latency on a TensorRT engine
python deploy/benchmark.py --path=/path/to/your/trtengine --coco_path=/path/to/your/COCODIR --run_benchmark 

8. Main Results

The main results on coco dataset. We report the mAP as reported in the original paper, as well as the mAP obtained from re-implementation.

| Method | pretraining | Params (M) | FLOPs (G) | Model Latency (ms) | Total Latency (ms) | mAP | Download | |:-----------|:-----------:|:-----------:|:-----------:|:-----------:|:-----------:|:-----------:|:-----------:| | LW-DETR-tiny | ✔ | 12.1 | 11.2 | 2.0 | 2.0 | 42.6(42.9) | Link | | LW-DETR-small | ✔ | 14.6 | 16.6 | 2.9 | 2.9 | 48.0(48.1) | Link | | LW-DETR-medium | ✔ | 28.2 | 42.8 | 5.6 | 5.6 | 52.5(52.6) | Link | | LW-DETR-large | ✔ | 46.8 | 71.6 | 8.8 | 8.8 | 56.1(56.1) | Link | | LW-DETR-xlarge | ✔ | 118.0| 174.2| 19.1| 19.1| 58.3(58.3) | Link |

9. References

Our project is conducted based on the following public paper with code:

10. Citation

If you find this code useful in your research, please kindly consider citing our paper:

    @article{chen2024lw,
        title={LW-DETR: A Transformer Replacement to YOLO for Real-Time Detection},
        author={Chen, Qiang and Su, Xiangbo and Zhang, Xinyu and Wang, Jian and Chen, Jiahui and Shen, Yunpeng and Han, Chuchu and Chen, Ziliang and Xu, Weixiang and Li, Fanrong and others},
        journal={arXiv preprint arXiv:2406.03459},
        year={2024}
    }
排名相邻
同类项目