Spaces:
Runtime error
Runtime error
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) | |