PyTorch Hub cv2 .save() .show() bug fix (#2831)
* PyTorch Hub cv2 .save() .show() bug fix cv2.rectangle() was failing on non-contiguous np array inputs. This checks for contiguous arrays and applies is necessary: ```python imgs[i] = im if im.data.contiguous else np.ascontiguousarray(im) # update ``` * Update plots.py ```python assert im.data.contiguous, 'Image not contiguous. Apply np.ascontiguousarray(im) to plot_on_box() input image.' ``` * Update hubconf.py Expand CI tests to OpenCV image.
This commit is contained in:
1 parent
aff03be35a
commit
c15e25c40f
3 files changed
+22
-18
No files matched your search
+6
-4
@@ -124,13 +124,15 @@ if __name__ == '__main__':
|
||||
# model = custom(path_or_model='path/to/model.pt') # custom example
|
||||
|
||||
# Verify inference
|
||||
import cv2
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
|
||||
imgs = [Image.open('data/images/bus.jpg'), # PIL
|
||||
'data/images/zidane.jpg', # filename
|
||||
'https://github.com/ultralytics/yolov5/raw/master/data/images/bus.jpg', # URI
|
||||
np.zeros((640, 480, 3))] # numpy
|
||||
imgs = ['data/images/zidane.jpg', # filename
|
||||
'https://github.com/ultralytics/yolov5/releases/download/v1.0/zidane.jpg', # URI
|
||||
cv2.imread('data/images/bus.jpg')[:, :, ::-1], # OpenCV
|
||||
Image.open('data/images/bus.jpg'), # PIL
|
||||
np.zeros((320, 640, 3))] # numpy
|
||||
|
||||
results = model(imgs) # batched inference
|
||||
results.print()
|
||||
|
||||
Reference in new issue
Block a user