img2gray / scripts /sanity.py
drbh
fix: improve python bindings and sanity check
aca891a
raw
history blame contribute delete
490 Bytes
import torch
import img2gray
from PIL import Image
import numpy as np
print(dir(img2gray))
img = Image.open("kernel-builder-logo-color.png").convert("RGB")
img = np.array(img)
img_tensor = torch.from_numpy(img).cuda()
print(img_tensor.shape) # HWC
gray_tensor = img2gray.img2gray(img_tensor).squeeze()
print(gray_tensor.shape) # HW
# save the output image
gray_img = Image.fromarray(gray_tensor.cpu().numpy().astype(np.uint8), mode="L")
gray_img.save("kernel-builder-logo-gray.png")