Downloads · 30 days
13
6% of all-time downloads
AnnaZhang/lwdetr_tiny_30e_objects365
lwdetr_tiny_30e_objects365 is a object detection model from AnnaZhang. Use it when you need objects located in an image. It is set up for transformers. The card lists the license as apache-2.0.
LW-DETR, a Light-Weight DEtection TRansformer model, is designed to be a real-time object detection alternative that outperforms conventional convolutional (YOLO-style) and earlier transformer-based (DETR) methods in…
Downloads · 30 days
13
6% of all-time downloads
All-time downloads
228
Public
Parameters
13M
52.2 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors52.2 MB · 100%
From the Hugging Face model README
LW-DETR, a Light-Weight DEtection TRansformer model, is designed to be a real-time object detection alternative that outperforms conventional convolutional (YOLO-style) and earlier transformer-based (DETR) methods in terms of speed and accuracy trade-off. It was introduced in the paper LW-DETR: A Transformer Replacement to YOLO for Real-Time Detection by Chen et al. and first released in this repository. Disclaimer: This model was originally contributed by stevenbucaille in 🤗 transformers.
LW-DETR is an end-to-end object detection model that uses a Vision Transformer (ViT) backbone as its encoder, a simple convolutional projector, and a shallow DETR decoder. The core philosophy is to leverage the power of transformers while implementing several efficiency-focused techniques to achieve real-time performance.
Key Architectural Details:
Training Details:
You can use the raw model for object detection. See the model hub to look for all available LW DETR models.
Here is how to use this model:
from transformers import AutoImageProcessor, LwDetrForObjectDetection
import torch
from PIL import Image
import requests
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
processor = AutoImageProcessor.from_pretrained("AnnaZhang/lwdetr_tiny_30e_objects365")
model = LwDetrForObjectDetection.from_pretrained("AnnaZhang/lwdetr_tiny_30e_objects365")
inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)
# convert outputs (bounding boxes and class logits) to COCO API
# let's only keep detections with score > 0.7
target_sizes = torch.tensor([image.size[::-1]])
results = processor.post_process_object_detection(outputs, target_sizes=target_sizes, threshold=0.7)[0]
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
box = [round(i, 2) for i in box.tolist()]
print(
f"Detected {model.config.id2label[label.item()]} with confidence "
f"{round(score.item(), 3)} at location {box}"
)
This should output:
Detected Jug with confidence 0.868 at location [4.89, 56.55, 319.81, 474.79]
Detected Refrigerator with confidence 0.753 at location [40.56, 73.11, 176.3, 116.86]
Detected Jug with confidence 0.718 at location [340.33, 25.1, 640.32, 368.68]
Currently, both the feature extractor and model support PyTorch.
The LW-DETR models are trained/finetuned on the following datasets:
@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}
}