0017それでも動く名無し 警備員[Lv.4][新芽]
2024/07/07(日) 09:10:20.74ID:5vwbDgEM00707Pythonというか動的型付け言語って初心者からしたらむずくね?
俺はこれでPython諦めた
def load_img(path):
image = Image.open(path).convert("RGB")
w, h = image.size
print(f"loaded input image of size ({w}, {h}) from {path}")
w, h = map(lambda x: x - x % 64, (w, h)) # resize to integer multiple of 64
image = image.resize((w, h), resample=PIL.Image.LANCZOS)
image = np.array(image).astype(np.float32) / 255.0
image = image[None].transpose(0, 3, 1, 2)
image = torch.from_numpy(image)
return 2. * image - 1.