minh14122003 commited on
Commit
bf031a2
·
verified ·
1 Parent(s): 446f7b3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +95 -12
README.md CHANGED
@@ -1,16 +1,99 @@
 
1
  license: apache-2.0
2
  tags:
3
- - object-detection
4
- - vision
5
  datasets:
6
- - coco
7
  widget:
8
- - src: >-
9
- https://huggingface.co/datasets/mishig/sample_images/resolve/main/savanna.jpg
10
- example_title: Savanna
11
- - src: >-
12
- https://huggingface.co/datasets/mishig/sample_images/resolve/main/football-match.jpg
13
- example_title: Football Match
14
- - src: >-
15
- https://huggingface.co/datasets/mishig/sample_images/resolve/main/airport.jpg
16
- example_title: Airport
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # YOLOS (tiny-sized) model
17
+
18
+ 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).
19
+
20
+ 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.
21
+
22
+ ## Model description
23
+
24
+ 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).
25
+
26
+ 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.
27
+
28
+ ## Intended uses & limitations
29
+
30
+ 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.
31
+
32
+ ### How to use
33
+
34
+ Here is how to use this model:
35
+
36
+ ```python
37
+ from transformers import YolosImageProcessor, YolosForObjectDetection
38
+ from PIL import Image
39
+ import torch
40
+ import requests
41
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
42
+ image = Image.open(requests.get(url, stream=True).raw)
43
+ model = YolosForObjectDetection.from_pretrained('hustvl/yolos-tiny')
44
+ image_processor = YolosImageProcessor.from_pretrained("hustvl/yolos-tiny")
45
+ inputs = image_processor(images=image, return_tensors="pt")
46
+ outputs = model(**inputs)
47
+ # model predicts bounding boxes and corresponding COCO classes
48
+ logits = outputs.logits
49
+ bboxes = outputs.pred_boxes
50
+ # print results
51
+ target_sizes = torch.tensor([image.size[::-1]])
52
+ results = image_processor.post_process_object_detection(outputs, threshold=0.9, target_sizes=target_sizes)[0]
53
+ for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
54
+ box = [round(i, 2) for i in box.tolist()]
55
+ print(
56
+ f"Detected {model.config.id2label[label.item()]} with confidence "
57
+ f"{round(score.item(), 3)} at location {box}"
58
+ )
59
+ ```
60
+
61
+ Currently, both the feature extractor and model support PyTorch.
62
+
63
+ ## Training data
64
+
65
+ 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.
66
+
67
+ ### Training
68
+
69
+ The model was pre-trained for 300 epochs on ImageNet-1k and fine-tuned for 300 epochs on COCO.
70
+
71
+ ## Evaluation results
72
+
73
+ 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.
74
+
75
+ ### BibTeX entry and citation info
76
+
77
+ ```bibtex
78
+ @article{DBLP:journals/corr/abs-2106-00666,
79
+ author = {Yuxin Fang and
80
+ Bencheng Liao and
81
+ Xinggang Wang and
82
+ Jiemin Fang and
83
+ Jiyang Qi and
84
+ Rui Wu and
85
+ Jianwei Niu and
86
+ Wenyu Liu},
87
+ title = {You Only Look at One Sequence: Rethinking Transformer in Vision through
88
+ Object Detection},
89
+ journal = {CoRR},
90
+ volume = {abs/2106.00666},
91
+ year = {2021},
92
+ url = {https://arxiv.org/abs/2106.00666},
93
+ eprinttype = {arXiv},
94
+ eprint = {2106.00666},
95
+ timestamp = {Fri, 29 Apr 2022 19:49:16 +0200},
96
+ biburl = {https://dblp.org/rec/journals/corr/abs-2106-00666.bib},
97
+ bibsource = {dblp computer science bibliography, https://dblp.org}
98
+ }
99
+ ```