Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
tags:
|
4 |
+
- object-detection
|
5 |
+
- vision
|
6 |
+
---
|
7 |
+
|
8 |
+
# Yolos-small-crowd
|
9 |
+
|
10 |
+
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).
|
11 |
+
|
12 |
+
## Model description
|
13 |
+
This model has been finetuned on the following [crowd-detection dataset](https://universe.roboflow.com/institut-teknologi-nasional-bandung-mxgtc/crowd-detection-i75bl) with the following results on the test set:
|
14 |
+
|
15 |
+
```
|
16 |
+
IoU metric: bbox
|
17 |
+
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.630
|
18 |
+
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.908
|
19 |
+
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.672
|
20 |
+
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
|
21 |
+
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.005
|
22 |
+
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.636
|
23 |
+
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.431
|
24 |
+
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.740
|
25 |
+
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.762
|
26 |
+
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
|
27 |
+
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.300
|
28 |
+
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.766
|
29 |
+
```
|
30 |
+
|
31 |
+
## How to use
|
32 |
+
|
33 |
+
```python
|
34 |
+
from transformers import AutoImageProcessor, AutoModelForObjectDetection
|
35 |
+
import torch
|
36 |
+
from PIL import Image
|
37 |
+
import requests
|
38 |
+
|
39 |
+
url = "https://latestbollyholly.com/wp-content/uploads/2024/02/Jacob-Gooch.jpg"
|
40 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
41 |
+
image_processor = AutoImageProcessor.from_pretrained("AdamCodd/yolos-small-crowd")
|
42 |
+
model = AutoModelForObjectDetection.from_pretrained("AdamCodd/yolos-small-crowd")
|
43 |
+
inputs = image_processor(images=image, return_tensors="pt")
|
44 |
+
outputs = model(**inputs)
|
45 |
+
|
46 |
+
# convert outputs (bounding boxes and class logits) to Pascal VOC format (xmin, ymin, xmax, ymax)
|
47 |
+
target_sizes = torch.tensor([image.size[::-1]])
|
48 |
+
results = image_processor.post_process_object_detection(outputs, threshold=0.7, target_sizes=target_sizes)[0]
|
49 |
+
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
|
50 |
+
box = [round(i, 2) for i in box.tolist()]
|
51 |
+
print(
|
52 |
+
f"Detected {model.config.id2label[label.item()]} with confidence "
|
53 |
+
f"{round(score.item(), 3)} at location {box}"
|
54 |
+
)
|
55 |
+
```
|
56 |
+
|
57 |
+
Refer to the [documentation](https://huggingface.co/docs/transformers/main/en/model_doc/yolos) for more code examples.
|
58 |
+
|
59 |
+
## Intended uses & limitations
|
60 |
+
|
61 |
+
This fine-tuned model performs best when detecting individuals who are relatively close to the viewpoint. As indicated by the metrics, it struggles to identify individuals farther away.
|
62 |
+
|
63 |
+
### Training hyperparameters
|
64 |
+
|
65 |
+
The following hyperparameters were used during training:
|
66 |
+
- learning_rate: 3e-05
|
67 |
+
- train_batch_size: 1
|
68 |
+
- eval_batch_size: 1
|
69 |
+
- seed: 42
|
70 |
+
- optimizer: AdamW with betas=(0.9,0.999) and epsilon=1e-08
|
71 |
+
- num_epochs: 5
|
72 |
+
- weight_decay: 1e-4
|
73 |
+
|
74 |
+
### Framework versions
|
75 |
+
|
76 |
+
- Transformers 4.36.2
|
77 |
+
- pycocotools 2.0.7
|
78 |
+
|
79 |
+
If you want to support me, you can [here](https://ko-fi.com/adamcodd).
|