glenn-jocher
commited on
Commit
•
2683b18
1
Parent(s):
1f31b7c
Update Hub Path inputs (#4200)
Browse files- hubconf.py +3 -1
- models/common.py +2 -2
hubconf.py
CHANGED
@@ -115,9 +115,11 @@ if __name__ == '__main__':
|
|
115 |
import cv2
|
116 |
import numpy as np
|
117 |
from PIL import Image
|
|
|
118 |
|
119 |
imgs = ['data/images/zidane.jpg', # filename
|
120 |
-
'
|
|
|
121 |
cv2.imread('data/images/bus.jpg')[:, :, ::-1], # OpenCV
|
122 |
Image.open('data/images/bus.jpg'), # PIL
|
123 |
np.zeros((320, 640, 3))] # numpy
|
|
|
115 |
import cv2
|
116 |
import numpy as np
|
117 |
from PIL import Image
|
118 |
+
from pathlib import Path
|
119 |
|
120 |
imgs = ['data/images/zidane.jpg', # filename
|
121 |
+
Path('data/images/zidane.jpg'), # Path
|
122 |
+
'https://ultralytics.com/images/zidane.jpg', # URI
|
123 |
cv2.imread('data/images/bus.jpg')[:, :, ::-1], # OpenCV
|
124 |
Image.open('data/images/bus.jpg'), # PIL
|
125 |
np.zeros((320, 640, 3))] # numpy
|
models/common.py
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
import logging
|
4 |
from copy import copy
|
5 |
-
from pathlib import Path
|
6 |
|
7 |
import math
|
8 |
import numpy as np
|
@@ -248,7 +248,7 @@ class AutoShape(nn.Module):
|
|
248 |
shape0, shape1, files = [], [], [] # image and inference shapes, filenames
|
249 |
for i, im in enumerate(imgs):
|
250 |
f = f'image{i}' # filename
|
251 |
-
if isinstance(im, (str,
|
252 |
im, f = Image.open(requests.get(im, stream=True).raw if str(im).startswith('http') else im), im
|
253 |
im = np.asarray(exif_transpose(im))
|
254 |
elif isinstance(im, Image.Image): # PIL Image
|
|
|
2 |
|
3 |
import logging
|
4 |
from copy import copy
|
5 |
+
from pathlib import Path
|
6 |
|
7 |
import math
|
8 |
import numpy as np
|
|
|
248 |
shape0, shape1, files = [], [], [] # image and inference shapes, filenames
|
249 |
for i, im in enumerate(imgs):
|
250 |
f = f'image{i}' # filename
|
251 |
+
if isinstance(im, (str, Path)): # filename or uri
|
252 |
im, f = Image.open(requests.get(im, stream=True).raw if str(im).startswith('http') else im), im
|
253 |
im = np.asarray(exif_transpose(im))
|
254 |
elif isinstance(im, Image.Image): # PIL Image
|