Unverified 提交 57ce73cd authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

Update datasets.py comments (#5088)

上级 ce8e5dc8
...@@ -155,7 +155,8 @@ class _RepeatSampler(object): ...@@ -155,7 +155,8 @@ class _RepeatSampler(object):
yield from iter(self.sampler) yield from iter(self.sampler)
class LoadImages: # for inference class LoadImages:
# YOLOv5 image/video dataloader, i.e. `python detect.py --source image.jpg/vid.mp4`
def __init__(self, path, img_size=640, stride=32, auto=True): def __init__(self, path, img_size=640, stride=32, auto=True):
p = str(Path(path).resolve()) # os-agnostic absolute path p = str(Path(path).resolve()) # os-agnostic absolute path
if '*' in p: if '*' in p:
...@@ -237,6 +238,7 @@ class LoadImages: # for inference ...@@ -237,6 +238,7 @@ class LoadImages: # for inference
class LoadWebcam: # for inference class LoadWebcam: # for inference
# YOLOv5 local webcam dataloader, i.e. `python detect.py --source 0`
def __init__(self, pipe='0', img_size=640, stride=32): def __init__(self, pipe='0', img_size=640, stride=32):
self.img_size = img_size self.img_size = img_size
self.stride = stride self.stride = stride
...@@ -277,7 +279,8 @@ class LoadWebcam: # for inference ...@@ -277,7 +279,8 @@ class LoadWebcam: # for inference
return 0 return 0
class LoadStreams: # multiple IP or RTSP cameras class LoadStreams:
# YOLOv5 streamloader, i.e. `python detect.py --source 'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP streams`
def __init__(self, sources='streams.txt', img_size=640, stride=32, auto=True): def __init__(self, sources='streams.txt', img_size=640, stride=32, auto=True):
self.mode = 'stream' self.mode = 'stream'
self.img_size = img_size self.img_size = img_size
...@@ -365,7 +368,8 @@ def img2label_paths(img_paths): ...@@ -365,7 +368,8 @@ def img2label_paths(img_paths):
return [sb.join(x.rsplit(sa, 1)).rsplit('.', 1)[0] + '.txt' for x in img_paths] return [sb.join(x.rsplit(sa, 1)).rsplit('.', 1)[0] + '.txt' for x in img_paths]
class LoadImagesAndLabels(Dataset): # for training/testing class LoadImagesAndLabels(Dataset):
# YOLOv5 train_loader/val_loader, loads images and labels for training and validation
cache_version = 0.5 # dataset labels *.cache version cache_version = 0.5 # dataset labels *.cache version
def __init__(self, path, img_size=640, batch_size=16, augment=False, hyp=None, rect=False, image_weights=False, def __init__(self, path, img_size=640, batch_size=16, augment=False, hyp=None, rect=False, image_weights=False,
...@@ -659,8 +663,7 @@ def load_image(self, i): ...@@ -659,8 +663,7 @@ def load_image(self, i):
def load_mosaic(self, index): def load_mosaic(self, index):
# loads images in a 4-mosaic # YOLOv5 4-mosaic loader. Loads 1 image + 3 random images into a 4-image mosaic
labels4, segments4 = [], [] labels4, segments4 = [], []
s = self.img_size s = self.img_size
yc, xc = [int(random.uniform(-x, 2 * s + x)) for x in self.mosaic_border] # mosaic center x, y yc, xc = [int(random.uniform(-x, 2 * s + x)) for x in self.mosaic_border] # mosaic center x, y
...@@ -717,8 +720,7 @@ def load_mosaic(self, index): ...@@ -717,8 +720,7 @@ def load_mosaic(self, index):
def load_mosaic9(self, index): def load_mosaic9(self, index):
# loads images in a 9-mosaic # YOLOv5 9-mosaic loader. Loads 1 image + 8 random images into a 9-image mosaic
labels9, segments9 = [], [] labels9, segments9 = [], []
s = self.img_size s = self.img_size
indices = [index] + random.choices(self.indices, k=8) # 8 additional image indices indices = [index] + random.choices(self.indices, k=8) # 8 additional image indices
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论