Created
April 3, 2022 17:44
-
-
Save robgon-art/4b96a922cc23375a595ffbdc85bf7203 to your computer and use it in GitHub Desktop.
Generate texture for an image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from torchvision import transforms as T | |
import torch | |
texture_amount = 0.15 | |
texture_size = 9 | |
noise = torch.normal(0, texture_amount*texture_size**(1./3.), | |
size=[resized.shape[0], 1, resized.shape[2], resized.shape[3]]).to(device) | |
noise = noise.repeat(1, 3, 1, 1) | |
noise_blurred = T.GaussianBlur(kernel_size=texture_size, sigma=1)(noise) | |
noise_blurred = noise*0.25 + noise_blurred*0.75 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment