MCPcopy
hub / github.com/pytorch/vision / make_image

Function make_image

test/common_utils.py:370–393  ·  view source on GitHub ↗
(
    size=DEFAULT_SIZE,
    *,
    color_space="RGB",
    batch_dims=(),
    dtype=None,
    device="cpu",
    memory_format=torch.contiguous_format,
)

Source from the content-addressed store, hash-verified

368
369
370def make_image(
371 size=DEFAULT_SIZE,
372 *,
373 color_space="RGB",
374 batch_dims=(),
375 dtype=None,
376 device="cpu",
377 memory_format=torch.contiguous_format,
378):
379 num_channels = NUM_CHANNELS_MAP[color_space]
380 dtype = dtype or torch.uint8
381 max_value = get_max_value(dtype)
382 data = torch.testing.make_tensor(
383 (*batch_dims, num_channels, *size),
384 low=0,
385 high=max_value,
386 dtype=dtype,
387 device=device,
388 memory_format=memory_format,
389 )
390 if color_space in {"GRAY_ALPHA", "RGBA"}:
391 data[..., -1, :, :] = max_value
392
393 return tv_tensors.Image(data)
394
395
396def make_image_tensor(*args, **kwargs):

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…