Commit
·
b937123
1
Parent(s):
1e8abec
Update README.md
Browse files
README.md
CHANGED
@@ -2,4 +2,48 @@
|
|
2 |
license: apache-2.0
|
3 |
---
|
4 |
|  |  |
|
5 |
-
| --- | --- |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
license: apache-2.0
|
3 |
---
|
4 |
|  |  |
|
5 |
+
| --- | --- |
|
6 |
+
|
7 |
+
|
8 |
+
- Install yolov5:
|
9 |
+
```bash
|
10 |
+
pip install yolov5==7.0.5
|
11 |
+
```
|
12 |
+
- Set image
|
13 |
+
|
14 |
+
```bash
|
15 |
+
wget -O 'image.jpg' 'https://images.unsplash.com/photo-1556767576-cf0a4a80e5b8?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8NXx8c3VwZXJtYXJrZXQlMjBzaGVsdmVzfGVufDB8fDB8fHww&w=1000&q=80'
|
16 |
+
```
|
17 |
+
- Load model and perform prediction:
|
18 |
+
|
19 |
+
```python
|
20 |
+
import yolov5
|
21 |
+
|
22 |
+
# load model
|
23 |
+
model = yolov5.load('Jonathancasjar/Retail_Shelves')
|
24 |
+
|
25 |
+
# set model parameters
|
26 |
+
model.conf = 0.25 # NMS confidence threshold
|
27 |
+
|
28 |
+
# set an image
|
29 |
+
img = '/content/image.jpg'
|
30 |
+
|
31 |
+
# perform inference
|
32 |
+
results = model(img, size=640)
|
33 |
+
|
34 |
+
# inference with test time augmentation
|
35 |
+
results = model(img, augment=True)
|
36 |
+
|
37 |
+
# parse results
|
38 |
+
predictions = results.pred[0]
|
39 |
+
boxes = predictions[:, :4] # x1, y1, x2, y2
|
40 |
+
scores = predictions[:, 4]
|
41 |
+
categories = predictions[:, 5]
|
42 |
+
|
43 |
+
# show detection bounding boxes on image
|
44 |
+
results.show()
|
45 |
+
|
46 |
+
# save results into "results/" folder
|
47 |
+
results.save(save_dir='results/')
|
48 |
+
```
|
49 |
+
|