Commit
·
37ad910
1
Parent(s):
65ee949
Update README.md
Browse files
README.md
CHANGED
|
@@ -90,14 +90,62 @@ Users should be informed about the model's limitations and potential biases. Fur
|
|
| 90 |
|
| 91 |
Load model and perform prediction:
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
import yolov5
|
| 95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
-
|
| 101 |
|
| 102 |
#### Hardware
|
| 103 |
|
|
|
|
| 90 |
|
| 91 |
Load model and perform prediction:
|
| 92 |
|
| 93 |
+
|
| 94 |
+
### How to use
|
| 95 |
+
|
| 96 |
+
- Install [yolov5](https://github.com/fcakyon/yolov5-pip):
|
| 97 |
+
|
| 98 |
+
```bash
|
| 99 |
+
pip install -U yolov5
|
| 100 |
```
|
| 101 |
+
|
| 102 |
+
- Load model and perform prediction:
|
| 103 |
+
|
| 104 |
+
```python
|
| 105 |
import yolov5
|
| 106 |
|
| 107 |
+
# load model
|
| 108 |
+
model = yolov5.load('foduucom/object_distance_estimation')
|
| 109 |
+
|
| 110 |
+
# set model parameters
|
| 111 |
+
model.conf = 0.25 # NMS confidence threshold
|
| 112 |
+
model.iou = 0.45 # NMS IoU threshold
|
| 113 |
+
model.agnostic = False # NMS class-agnostic
|
| 114 |
+
model.multi_label = False # NMS multiple labels per box
|
| 115 |
+
model.max_det = 1000 # maximum number of detections per image
|
| 116 |
+
|
| 117 |
+
# set image
|
| 118 |
+
img = path
|
| 119 |
+
|
| 120 |
+
# perform inference
|
| 121 |
+
results = model(img, size=640)
|
| 122 |
+
|
| 123 |
+
# inference with test time augmentation
|
| 124 |
+
results = model(img, augment=True)
|
| 125 |
+
|
| 126 |
+
# parse results
|
| 127 |
+
predictions = results.pred[0]
|
| 128 |
+
boxes = predictions[:, :4] # x1, y1, x2, y2
|
| 129 |
+
scores = predictions[:, 4]
|
| 130 |
+
categories = predictions[:, 5]
|
| 131 |
+
|
| 132 |
+
# show detection bounding boxes on image
|
| 133 |
+
results.show()
|
| 134 |
+
|
| 135 |
+
# save results into "results/" folder
|
| 136 |
+
results.save(save_dir='results/')
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
- Finetune the model on your custom dataset:
|
| 140 |
+
|
| 141 |
+
```bash
|
| 142 |
+
yolov5 train --data dataset.yaml --img 640 --batch -1 --weights foduucom/object_distance_estimation --epochs 10
|
| 143 |
+
```
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
+
### Compute Infrastructure
|
| 149 |
|
| 150 |
#### Hardware
|
| 151 |
|