(
size=DEFAULT_SIZE,
*,
color_space="RGB",
batch_dims=(),
dtype=None,
device="cpu",
memory_format=torch.contiguous_format,
)
| 368 | |
| 369 | |
| 370 | def 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 | |
| 396 | def make_image_tensor(*args, **kwargs): |
no outgoing calls
searching dependent graphs…