Add yolov5 model card
Browse files
README.md
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
---
|
3 |
+
tags:
|
4 |
+
- yolov5
|
5 |
+
- yolo
|
6 |
+
- vision
|
7 |
+
- object-detection
|
8 |
+
- pytorch
|
9 |
+
library_name: yolov5
|
10 |
+
library_version: 7.0.7
|
11 |
+
inference: false
|
12 |
+
|
13 |
+
model-index:
|
14 |
+
- name: uisikdag/hardhat
|
15 |
+
results:
|
16 |
+
- task:
|
17 |
+
type: object-detection
|
18 |
+
|
19 |
+
metrics:
|
20 |
+
- type: precision # since mAP@0.5 is not available on hf.co/metrics
|
21 |
+
value: 0.9284727818930048 # min: 0.0 - max: 1.0
|
22 |
+
name: mAP@0.5
|
23 |
+
---
|
24 |
+
|
25 |
+
<div align="center">
|
26 |
+
<img width="640" alt="uisikdag/hardhat" src="https://huggingface.co/uisikdag/hardhat/resolve/main/sample_visuals.jpg">
|
27 |
+
</div>
|
28 |
+
|
29 |
+
### How to use
|
30 |
+
|
31 |
+
- Install [yolov5](https://github.com/fcakyon/yolov5-pip):
|
32 |
+
|
33 |
+
```bash
|
34 |
+
pip install -U yolov5
|
35 |
+
```
|
36 |
+
|
37 |
+
- Load model and perform prediction:
|
38 |
+
|
39 |
+
```python
|
40 |
+
import yolov5
|
41 |
+
|
42 |
+
# load model
|
43 |
+
model = yolov5.load('uisikdag/hardhat')
|
44 |
+
|
45 |
+
# set model parameters
|
46 |
+
model.conf = 0.25 # NMS confidence threshold
|
47 |
+
model.iou = 0.45 # NMS IoU threshold
|
48 |
+
model.agnostic = False # NMS class-agnostic
|
49 |
+
model.multi_label = False # NMS multiple labels per box
|
50 |
+
model.max_det = 1000 # maximum number of detections per image
|
51 |
+
|
52 |
+
# set image
|
53 |
+
img = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'
|
54 |
+
|
55 |
+
# perform inference
|
56 |
+
results = model(img, size=640)
|
57 |
+
|
58 |
+
# inference with test time augmentation
|
59 |
+
results = model(img, augment=True)
|
60 |
+
|
61 |
+
# parse results
|
62 |
+
predictions = results.pred[0]
|
63 |
+
boxes = predictions[:, :4] # x1, y1, x2, y2
|
64 |
+
scores = predictions[:, 4]
|
65 |
+
categories = predictions[:, 5]
|
66 |
+
|
67 |
+
# show detection bounding boxes on image
|
68 |
+
results.show()
|
69 |
+
|
70 |
+
# save results into "results/" folder
|
71 |
+
results.save(save_dir='results/')
|
72 |
+
```
|
73 |
+
|
74 |
+
- Finetune the model on your custom dataset:
|
75 |
+
|
76 |
+
```bash
|
77 |
+
yolov5 train --data data.yaml --img 640 --batch 16 --weights uisikdag/hardhat --epochs 10
|
78 |
+
```
|
79 |
+
|
80 |
+
**More models available at: [awesome-yolov5-models](https://github.com/keremberke/awesome-yolov5-models)**
|