StyleRes / datasets /demo_dataset.py
hamzapehlivan
Intial Commit
6709fc9
raw
history blame
321 Bytes
import numpy as np
import torch
def preprocess_demo_image(image):
image = image.resize( (256, 256))
image = np.asarray(image).transpose(2, 0, 1).astype(np.float32) # C,H,W -> H,W,C
image = torch.FloatTensor(image.copy())
image = (image - 127.5) / 127.5 # Normalize
return image.unsqueeze(0)