MCPcopy Create free account
hub / github.com/IceClear/StableSR / load_img

Function load_img

predict.py:271–280  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

269
270
271def load_img(path):
272 image = Image.open(path).convert("RGB")
273 w, h = image.size
274 print(f"loaded input image of size ({w}, {h}) from {path}")
275 w, h = map(lambda x: x - x % 32, (w, h)) # resize to integer multiple of 32
276 image = image.resize((w, h), resample=PIL.Image.LANCZOS)
277 image = np.array(image).astype(np.float32) / 255.0
278 image = image[None].transpose(0, 3, 1, 2)
279 image = torch.from_numpy(image)
280 return 2.0 * image - 1.0

Callers 1

predictMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected