This commit is contained in:
Glenn Jocher 2019-12-08 17:00:13 -08:00
parent 50866ddaa9
commit b913d1ab55
1 changed files with 8 additions and 8 deletions

View File

@ -101,8 +101,8 @@ class LoadImages: # for inference
# Padded resize # Padded resize
img = letterbox(img0, new_shape=self.img_size)[0] img = letterbox(img0, new_shape=self.img_size)[0]
# Normalize RGB # Convert
img = img[:, :, ::-1].transpose(2, 0, 1) # BGR to RGB img = img[:, :, ::-1].transpose(2, 0, 1) # BGR to RGB, to 3x416x416
img = np.ascontiguousarray(img, dtype=np.float16 if self.half else np.float32) # uint8 to fp16/fp32 img = np.ascontiguousarray(img, dtype=np.float16 if self.half else np.float32) # uint8 to fp16/fp32
img /= 255.0 # 0 - 255 to 0.0 - 1.0 img /= 255.0 # 0 - 255 to 0.0 - 1.0
@ -174,8 +174,8 @@ class LoadWebcam: # for inference
# Padded resize # Padded resize
img = letterbox(img0, new_shape=self.img_size)[0] img = letterbox(img0, new_shape=self.img_size)[0]
# Normalize RGB # Convert
img = img[:, :, ::-1].transpose(2, 0, 1) # BGR to RGB img = img[:, :, ::-1].transpose(2, 0, 1) # BGR to RGB, to 3x416x416
img = np.ascontiguousarray(img, dtype=np.float16 if self.half else np.float32) # uint8 to fp16/fp32 img = np.ascontiguousarray(img, dtype=np.float16 if self.half else np.float32) # uint8 to fp16/fp32
img /= 255.0 # 0 - 255 to 0.0 - 1.0 img /= 255.0 # 0 - 255 to 0.0 - 1.0
@ -243,9 +243,9 @@ class LoadStreams: # multiple IP or RTSP cameras
# Stack # Stack
img = np.stack(img, 0) img = np.stack(img, 0)
# Normalize RGB # Convert
img = img[:, :, :, ::-1].transpose(0, 3, 1, 2) # BGR to RGB img = img[:, :, :, ::-1].transpose(0, 3, 1, 2) # BGR to RGB, to 3x416x416, uint8 to float32
img = np.ascontiguousarray(img, dtype=np.float16 if self.half else np.float32) # uint8 to fp16/fp32 img = np.ascontiguousarray(img, dtype=np.float16 if self.half else np.float32)
img /= 255.0 # 0 - 255 to 0.0 - 1.0 img /= 255.0 # 0 - 255 to 0.0 - 1.0
return self.sources, img, img0, None return self.sources, img, img0, None
@ -485,7 +485,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing
if nL: if nL:
labels_out[:, 1:] = torch.from_numpy(labels) labels_out[:, 1:] = torch.from_numpy(labels)
# Normalize # Convert
img = img[:, :, ::-1].transpose(2, 0, 1) # BGR to RGB, to 3x416x416 img = img[:, :, ::-1].transpose(2, 0, 1) # BGR to RGB, to 3x416x416
img = np.ascontiguousarray(img, dtype=np.float32) # uint8 to float32 img = np.ascontiguousarray(img, dtype=np.float32) # uint8 to float32
img /= 255.0 # 0 - 255 to 0.0 - 1.0 img /= 255.0 # 0 - 255 to 0.0 - 1.0