18 lines
434 B
Python
18 lines
434 B
Python
from PIL import Image, ImageDraw, ImageFilter
|
|
import torch
|
|
import numpy as np
|
|
|
|
|
|
def pil2tensor(image):
|
|
return torch.from_numpy(np.array(image).astype(np.float32) / 255.0).unsqueeze(0)
|
|
|
|
|
|
def empty_pil_tensor(w=64, h=64):
|
|
image = Image.new("RGB", (w, h))
|
|
draw = ImageDraw.Draw(image)
|
|
draw.rectangle((0, 0, w-1, h-1), fill=(0, 0, 0))
|
|
return pil2tensor(image)
|
|
|
|
|
|
def empty_latent():
|
|
return torch.zeros([1, 4, 8, 8]) |