glenn-jocher commited on
Commit
57ce73c
·
unverified ·
1 Parent(s): ce8e5dc

Update datasets.py comments (#5088)

Browse files
Files changed (1) hide show
  1. utils/datasets.py +9 -7
utils/datasets.py CHANGED
@@ -155,7 +155,8 @@ class _RepeatSampler(object):
155
  yield from iter(self.sampler)
156
 
157
 
158
- class LoadImages: # for inference
 
159
  def __init__(self, path, img_size=640, stride=32, auto=True):
160
  p = str(Path(path).resolve()) # os-agnostic absolute path
161
  if '*' in p:
@@ -237,6 +238,7 @@ class LoadImages: # for inference
237
 
238
 
239
  class LoadWebcam: # for inference
 
240
  def __init__(self, pipe='0', img_size=640, stride=32):
241
  self.img_size = img_size
242
  self.stride = stride
@@ -277,7 +279,8 @@ class LoadWebcam: # for inference
277
  return 0
278
 
279
 
280
- class LoadStreams: # multiple IP or RTSP cameras
 
281
  def __init__(self, sources='streams.txt', img_size=640, stride=32, auto=True):
282
  self.mode = 'stream'
283
  self.img_size = img_size
@@ -365,7 +368,8 @@ def img2label_paths(img_paths):
365
  return [sb.join(x.rsplit(sa, 1)).rsplit('.', 1)[0] + '.txt' for x in img_paths]
366
 
367
 
368
- class LoadImagesAndLabels(Dataset): # for training/testing
 
369
  cache_version = 0.5 # dataset labels *.cache version
370
 
371
  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
 
660
 
661
  def load_mosaic(self, index):
662
- # loads images in a 4-mosaic
663
-
664
  labels4, segments4 = [], []
665
  s = self.img_size
666
  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
 
718
 
719
  def load_mosaic9(self, index):
720
- # loads images in a 9-mosaic
721
-
722
  labels9, segments9 = [], []
723
  s = self.img_size
724
  indices = [index] + random.choices(self.indices, k=8) # 8 additional image indices
 
155
  yield from iter(self.sampler)
156
 
157
 
158
+ class LoadImages:
159
+ # YOLOv5 image/video dataloader, i.e. `python detect.py --source image.jpg/vid.mp4`
160
  def __init__(self, path, img_size=640, stride=32, auto=True):
161
  p = str(Path(path).resolve()) # os-agnostic absolute path
162
  if '*' in p:
 
238
 
239
 
240
  class LoadWebcam: # for inference
241
+ # YOLOv5 local webcam dataloader, i.e. `python detect.py --source 0`
242
  def __init__(self, pipe='0', img_size=640, stride=32):
243
  self.img_size = img_size
244
  self.stride = stride
 
279
  return 0
280
 
281
 
282
+ class LoadStreams:
283
+ # YOLOv5 streamloader, i.e. `python detect.py --source 'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP streams`
284
  def __init__(self, sources='streams.txt', img_size=640, stride=32, auto=True):
285
  self.mode = 'stream'
286
  self.img_size = img_size
 
368
  return [sb.join(x.rsplit(sa, 1)).rsplit('.', 1)[0] + '.txt' for x in img_paths]
369
 
370
 
371
+ class LoadImagesAndLabels(Dataset):
372
+ # YOLOv5 train_loader/val_loader, loads images and labels for training and validation
373
  cache_version = 0.5 # dataset labels *.cache version
374
 
375
  def __init__(self, path, img_size=640, batch_size=16, augment=False, hyp=None, rect=False, image_weights=False,
 
663
 
664
 
665
  def load_mosaic(self, index):
666
+ # YOLOv5 4-mosaic loader. Loads 1 image + 3 random images into a 4-image mosaic
 
667
  labels4, segments4 = [], []
668
  s = self.img_size
669
  yc, xc = [int(random.uniform(-x, 2 * s + x)) for x in self.mosaic_border] # mosaic center x, y
 
720
 
721
 
722
  def load_mosaic9(self, index):
723
+ # YOLOv5 9-mosaic loader. Loads 1 image + 8 random images into a 9-image mosaic
 
724
  labels9, segments9 = [], []
725
  s = self.img_size
726
  indices = [index] + random.choices(self.indices, k=8) # 8 additional image indices