Improved hubconf.py CI tests (#2251)
Browse files- hubconf.py +7 -2
- models/common.py +1 -1
hubconf.py
CHANGED
@@ -133,9 +133,14 @@ if __name__ == '__main__':
|
|
133 |
# model = custom(path_or_model='path/to/model.pt') # custom example
|
134 |
|
135 |
# Verify inference
|
|
|
136 |
from PIL import Image
|
137 |
|
138 |
-
imgs = [Image.open(
|
139 |
-
|
|
|
|
|
|
|
|
|
140 |
results.print()
|
141 |
results.save()
|
|
|
133 |
# model = custom(path_or_model='path/to/model.pt') # custom example
|
134 |
|
135 |
# Verify inference
|
136 |
+
import numpy as np
|
137 |
from PIL import Image
|
138 |
|
139 |
+
imgs = [Image.open('data/images/bus.jpg'), # PIL
|
140 |
+
'data/images/zidane.jpg', # filename
|
141 |
+
'https://github.com/ultralytics/yolov5/raw/master/data/images/bus.jpg', # URI
|
142 |
+
np.zeros((640, 480, 3))] # numpy
|
143 |
+
|
144 |
+
results = model(imgs) # batched inference
|
145 |
results.print()
|
146 |
results.save()
|
models/common.py
CHANGED
@@ -254,7 +254,7 @@ class Detections:
|
|
254 |
n = (pred[:, -1] == c).sum() # detections per class
|
255 |
str += f"{n} {self.names[int(c)]}{'s' * (n > 1)}, " # add to string
|
256 |
if show or save or render:
|
257 |
-
img = Image.fromarray(img) if isinstance(img, np.ndarray) else img # from np
|
258 |
for *box, conf, cls in pred: # xyxy, confidence, class
|
259 |
# str += '%s %.2f, ' % (names[int(cls)], conf) # label
|
260 |
ImageDraw.Draw(img).rectangle(box, width=4, outline=colors[int(cls) % 10]) # plot
|
|
|
254 |
n = (pred[:, -1] == c).sum() # detections per class
|
255 |
str += f"{n} {self.names[int(c)]}{'s' * (n > 1)}, " # add to string
|
256 |
if show or save or render:
|
257 |
+
img = Image.fromarray(img.astype(np.uint8)) if isinstance(img, np.ndarray) else img # from np
|
258 |
for *box, conf, cls in pred: # xyxy, confidence, class
|
259 |
# str += '%s %.2f, ' % (names[int(cls)], conf) # label
|
260 |
ImageDraw.Draw(img).rectangle(box, width=4, outline=colors[int(cls) % 10]) # plot
|