Delete README.md
Browse files
README.md
DELETED
|
@@ -1,106 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
tags:
|
| 4 |
-
- object-detection
|
| 5 |
-
- vision
|
| 6 |
-
datasets:
|
| 7 |
-
- coco
|
| 8 |
-
widget:
|
| 9 |
-
- src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/savanna.jpg
|
| 10 |
-
example_title: Savanna
|
| 11 |
-
- src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/football-match.jpg
|
| 12 |
-
example_title: Football Match
|
| 13 |
-
- src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/airport.jpg
|
| 14 |
-
example_title: Airport
|
| 15 |
-
---
|
| 16 |
-
|
| 17 |
-
# YOLOS (tiny-sized) model
|
| 18 |
-
|
| 19 |
-
YOLOS model fine-tuned on COCO 2017 object detection (118k annotated images). It was introduced in the paper [You Only Look at One Sequence: Rethinking Transformer in Vision through Object Detection](https://arxiv.org/abs/2106.00666) by Fang et al. and first released in [this repository](https://github.com/hustvl/YOLOS).
|
| 20 |
-
|
| 21 |
-
Disclaimer: The team releasing YOLOS did not write a model card for this model so this model card has been written by the Hugging Face team.
|
| 22 |
-
|
| 23 |
-
## Model description
|
| 24 |
-
|
| 25 |
-
YOLOS is a Vision Transformer (ViT) trained using the DETR loss. Despite its simplicity, a base-sized YOLOS model is able to achieve 42 AP on COCO validation 2017 (similar to DETR and more complex frameworks such as Faster R-CNN).
|
| 26 |
-
|
| 27 |
-
The model is trained using a "bipartite matching loss": one compares the predicted classes + bounding boxes of each of the N = 100 object queries to the ground truth annotations, padded up to the same length N (so if an image only contains 4 objects, 96 annotations will just have a "no object" as class and "no bounding box" as bounding box). The Hungarian matching algorithm is used to create an optimal one-to-one mapping between each of the N queries and each of the N annotations. Next, standard cross-entropy (for the classes) and a linear combination of the L1 and generalized IoU loss (for the bounding boxes) are used to optimize the parameters of the model.
|
| 28 |
-
|
| 29 |
-
## Intended uses & limitations
|
| 30 |
-
|
| 31 |
-
You can use the raw model for object detection. See the [model hub](https://huggingface.co/models?search=hustvl/yolos) to look for all available YOLOS models.
|
| 32 |
-
|
| 33 |
-
### How to use
|
| 34 |
-
|
| 35 |
-
Here is how to use this model:
|
| 36 |
-
|
| 37 |
-
```python
|
| 38 |
-
from transformers import YolosImageProcessor, YolosForObjectDetection
|
| 39 |
-
from PIL import Image
|
| 40 |
-
import torch
|
| 41 |
-
import requests
|
| 42 |
-
|
| 43 |
-
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
| 44 |
-
image = Image.open(requests.get(url, stream=True).raw)
|
| 45 |
-
|
| 46 |
-
model = YolosForObjectDetection.from_pretrained('hustvl/yolos-tiny')
|
| 47 |
-
image_processor = YolosImageProcessor.from_pretrained("hustvl/yolos-tiny")
|
| 48 |
-
|
| 49 |
-
inputs = image_processor(images=image, return_tensors="pt")
|
| 50 |
-
outputs = model(**inputs)
|
| 51 |
-
|
| 52 |
-
# model predicts bounding boxes and corresponding COCO classes
|
| 53 |
-
logits = outputs.logits
|
| 54 |
-
bboxes = outputs.pred_boxes
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
# print results
|
| 58 |
-
target_sizes = torch.tensor([image.size[::-1]])
|
| 59 |
-
results = image_processor.post_process_object_detection(outputs, threshold=0.9, target_sizes=target_sizes)[0]
|
| 60 |
-
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
|
| 61 |
-
box = [round(i, 2) for i in box.tolist()]
|
| 62 |
-
print(
|
| 63 |
-
f"Detected {model.config.id2label[label.item()]} with confidence "
|
| 64 |
-
f"{round(score.item(), 3)} at location {box}"
|
| 65 |
-
)
|
| 66 |
-
```
|
| 67 |
-
|
| 68 |
-
Currently, both the feature extractor and model support PyTorch.
|
| 69 |
-
|
| 70 |
-
## Training data
|
| 71 |
-
|
| 72 |
-
The YOLOS model was pre-trained on [ImageNet-1k](https://huggingface.co/datasets/imagenet2012) and fine-tuned on [COCO 2017 object detection](https://cocodataset.org/#download), a dataset consisting of 118k/5k annotated images for training/validation respectively.
|
| 73 |
-
|
| 74 |
-
### Training
|
| 75 |
-
|
| 76 |
-
The model was pre-trained for 300 epochs on ImageNet-1k and fine-tuned for 300 epochs on COCO.
|
| 77 |
-
|
| 78 |
-
## Evaluation results
|
| 79 |
-
|
| 80 |
-
This model achieves an AP (average precision) of **28.7** on COCO 2017 validation. For more details regarding evaluation results, we refer to the original paper.
|
| 81 |
-
|
| 82 |
-
### BibTeX entry and citation info
|
| 83 |
-
|
| 84 |
-
```bibtex
|
| 85 |
-
@article{DBLP:journals/corr/abs-2106-00666,
|
| 86 |
-
author = {Yuxin Fang and
|
| 87 |
-
Bencheng Liao and
|
| 88 |
-
Xinggang Wang and
|
| 89 |
-
Jiemin Fang and
|
| 90 |
-
Jiyang Qi and
|
| 91 |
-
Rui Wu and
|
| 92 |
-
Jianwei Niu and
|
| 93 |
-
Wenyu Liu},
|
| 94 |
-
title = {You Only Look at One Sequence: Rethinking Transformer in Vision through
|
| 95 |
-
Object Detection},
|
| 96 |
-
journal = {CoRR},
|
| 97 |
-
volume = {abs/2106.00666},
|
| 98 |
-
year = {2021},
|
| 99 |
-
url = {https://arxiv.org/abs/2106.00666},
|
| 100 |
-
eprinttype = {arXiv},
|
| 101 |
-
eprint = {2106.00666},
|
| 102 |
-
timestamp = {Fri, 29 Apr 2022 19:49:16 +0200},
|
| 103 |
-
biburl = {https://dblp.org/rec/journals/corr/abs-2106-00666.bib},
|
| 104 |
-
bibsource = {dblp computer science bibliography, https://dblp.org}
|
| 105 |
-
}
|
| 106 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|