MCPcopy Create free account
hub / github.com/OpenGVLab/UniFormerV2 / grayscale

Function grayscale

slowfast/datasets/transform.py:328–347  ·  view source on GitHub ↗

Get the grayscale for the input images. The channels of images should be in order BGR. Args: images (tensor): the input images for getting grayscale. Dimension is `num frames` x `channel` x `height` x `width`. Returns: img_gray (tensor): blended images, t

(images)

Source from the content-addressed store, hash-verified

326
327
328def grayscale(images):
329 """
330 Get the grayscale for the input images. The channels of images should be
331 in order BGR.
332 Args:
333 images (tensor): the input images for getting grayscale. Dimension is
334 `num frames` x `channel` x `height` x `width`.
335 Returns:
336 img_gray (tensor): blended images, the dimension is
337 `num frames` x `channel` x `height` x `width`.
338 """
339 # R -> 0.299, G -> 0.587, B -> 0.114.
340 img_gray = torch.tensor(images)
341 gray_channel = (
342 0.299 * images[:, 2] + 0.587 * images[:, 1] + 0.114 * images[:, 0]
343 )
344 img_gray[:, 0] = gray_channel
345 img_gray[:, 1] = gray_channel
346 img_gray[:, 2] = gray_channel
347 return img_gray
348
349
350def color_jitter(images, img_brightness=0, img_contrast=0, img_saturation=0):

Callers 2

contrast_jitterFunction · 0.70
saturation_jitterFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected