Commit
·
660772f
1
Parent(s):
ab62755
Update README.md
Browse files
README.md
CHANGED
@@ -94,35 +94,28 @@ pip install transformers
|
|
94 |
|
95 |
```python
|
96 |
|
97 |
-
from
|
98 |
-
from PIL import Image
|
99 |
-
import torch
|
100 |
-
import requests
|
101 |
|
102 |
-
|
103 |
-
|
104 |
|
105 |
-
model
|
106 |
-
|
|
|
|
|
|
|
107 |
|
108 |
-
|
109 |
-
|
110 |
|
111 |
-
#
|
112 |
-
|
113 |
-
bboxes = outputs.pred_boxes
|
114 |
-
|
115 |
-
|
116 |
-
# print results
|
117 |
-
target_sizes = torch.tensor([image.size[::-1]])
|
118 |
-
results = image_processor.post_process_object_detection(outputs, threshold=0.9, target_sizes=target_sizes)[0]
|
119 |
-
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
|
120 |
-
box = [round(i, 2) for i in box.tolist()]
|
121 |
-
print(
|
122 |
-
f"Detected {model.config.id2label[label.item()]} with confidence "
|
123 |
-
f"{round(score.item(), 3)} at location {box}"
|
124 |
-
)
|
125 |
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
### Compute Infrastructure
|
128 |
|
|
|
94 |
|
95 |
```python
|
96 |
|
97 |
+
from ultralyticsplus import YOLO, render_result
|
|
|
|
|
|
|
98 |
|
99 |
+
# load model
|
100 |
+
model = YOLO('foduucom/thermal-image-object-detection')
|
101 |
|
102 |
+
# set model parameters
|
103 |
+
model.overrides['conf'] = 0.25 # NMS confidence threshold
|
104 |
+
model.overrides['iou'] = 0.45 # NMS IoU threshold
|
105 |
+
model.overrides['agnostic_nms'] = False # NMS class-agnostic
|
106 |
+
model.overrides['max_det'] = 1000 # maximum number of detections per image
|
107 |
|
108 |
+
# set image
|
109 |
+
image = '/path/to/your/document/images'
|
110 |
|
111 |
+
# perform inference
|
112 |
+
results = model.predict(image)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
+
# observe results
|
115 |
+
print(results[0].boxes)
|
116 |
+
render = render_result(model=model, image=image, result=results[0])
|
117 |
+
render.show()
|
118 |
+
```
|
119 |
|
120 |
### Compute Infrastructure
|
121 |
|