turhancan97
commited on
Commit
·
a9e6983
1
Parent(s):
bf48e68
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,68 @@
|
|
1 |
---
|
2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: mit
|
3 |
+
datasets:
|
4 |
+
- garythung/trashnet
|
5 |
+
- Zesky665/TACO
|
6 |
+
- detection-datasets/coco
|
7 |
+
language:
|
8 |
+
- en
|
9 |
+
tags:
|
10 |
+
- object-detection
|
11 |
+
- computer-vision
|
12 |
+
- yolov5
|
13 |
---
|
14 |
+
|
15 |
+
<div align="center">
|
16 |
+
<img width="416" alt="turhancan97/yolov5-detect-trash-classification" src="https://huggingface.co/turhancan97/yolov5-detect-trash-classification/resolve/main/example1.jpg">
|
17 |
+
</div>
|
18 |
+
|
19 |
+
### How to use
|
20 |
+
|
21 |
+
- Install [yolov5](https://github.com/fcakyon/yolov5-pip):
|
22 |
+
|
23 |
+
```bash
|
24 |
+
pip install -U yolov5
|
25 |
+
```
|
26 |
+
|
27 |
+
- Load model and perform prediction:
|
28 |
+
|
29 |
+
```python
|
30 |
+
import yolov5
|
31 |
+
|
32 |
+
# load model
|
33 |
+
model = yolov5.load('turhancan97/yolov5-detect-trash-classification')
|
34 |
+
|
35 |
+
# set model parameters
|
36 |
+
model.conf = 0.25 # NMS confidence threshold
|
37 |
+
model.iou = 0.45 # NMS IoU threshold
|
38 |
+
model.agnostic = False # NMS class-agnostic
|
39 |
+
model.multi_label = False # NMS multiple labels per box
|
40 |
+
model.max_det = 1000 # maximum number of detections per image
|
41 |
+
|
42 |
+
# set image
|
43 |
+
img = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'
|
44 |
+
|
45 |
+
# perform inference
|
46 |
+
results = model(img, size=640)
|
47 |
+
|
48 |
+
# inference with test time augmentation
|
49 |
+
results = model(img, augment=True)
|
50 |
+
|
51 |
+
# parse results
|
52 |
+
predictions = results.pred[0]
|
53 |
+
boxes = predictions[:, :4] # x1, y1, x2, y2
|
54 |
+
scores = predictions[:, 4]
|
55 |
+
categories = predictions[:, 5]
|
56 |
+
|
57 |
+
# show detection bounding boxes on image
|
58 |
+
results.show()
|
59 |
+
|
60 |
+
# save results into "results/" folder
|
61 |
+
results.save(save_dir='results/')
|
62 |
+
```
|
63 |
+
|
64 |
+
- Finetune the model on your custom dataset:
|
65 |
+
|
66 |
+
```bash
|
67 |
+
yolov5 train --data data.yaml --img 416 --batch 16 --weights turhancan97/yolov5-detect-trash-classification --epochs 10
|
68 |
+
```
|