RandomPosterize¶ class torchvision.transforms.RandomPosterize(bits, p=0.5)[原始碼]¶ 透過以給定機率隨機銳化影像,減少每個顏色通道的位數。如果影像是 torch Tensor,則其型別應為 torch.uint8,並且期望其形狀為 [..., 1 或 3, H, W],其中 ... 表示任意數量的前導維度。如果 img 是 PIL Image,則期望其模式為“L”或“RGB”。 引數: bits (int) – 為每個通道保留的位數(0-8) p (float) – 影像被銳化的機率。預設值為 0.5 使用 RandomPosterize 的示例 轉換圖示 轉換圖示 forward(img)[原始碼]¶ 引數: img (PIL Image 或 Tensor) – 要銳化的影像。 返回: 隨機銳化後的影像。 返回型別: PIL 影像或張量