Browse Source

Update Hub Path inputs (#4200)

modifyDataloader
Glenn Jocher GitHub 3 years ago
parent
commit
2683b18079
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions
  1. +3
    -1
      hubconf.py
  2. +2
    -2
      models/common.py

+ 3
- 1
hubconf.py View File

import cv2 import cv2
import numpy as np import numpy as np
from PIL import Image from PIL import Image
from pathlib import Path


imgs = ['data/images/zidane.jpg', # filename imgs = ['data/images/zidane.jpg', # filename
'https://github.com/ultralytics/yolov5/releases/download/v1.0/zidane.jpg', # URI
Path('data/images/zidane.jpg'), # Path
'https://ultralytics.com/images/zidane.jpg', # URI
cv2.imread('data/images/bus.jpg')[:, :, ::-1], # OpenCV cv2.imread('data/images/bus.jpg')[:, :, ::-1], # OpenCV
Image.open('data/images/bus.jpg'), # PIL Image.open('data/images/bus.jpg'), # PIL
np.zeros((320, 640, 3))] # numpy np.zeros((320, 640, 3))] # numpy

+ 2
- 2
models/common.py View File



import logging import logging
from copy import copy from copy import copy
from pathlib import Path, PosixPath
from pathlib import Path


import math import math
import numpy as np import numpy as np
shape0, shape1, files = [], [], [] # image and inference shapes, filenames shape0, shape1, files = [], [], [] # image and inference shapes, filenames
for i, im in enumerate(imgs): for i, im in enumerate(imgs):
f = f'image{i}' # filename f = f'image{i}' # filename
if isinstance(im, (str, PosixPath)): # filename or uri
if isinstance(im, (str, Path)): # filename or uri
im, f = Image.open(requests.get(im, stream=True).raw if str(im).startswith('http') else im), im im, f = Image.open(requests.get(im, stream=True).raw if str(im).startswith('http') else im), im
im = np.asarray(exif_transpose(im)) im = np.asarray(exif_transpose(im))
elif isinstance(im, Image.Image): # PIL Image elif isinstance(im, Image.Image): # PIL Image

Loading…
Cancel
Save