diff options
author | Aarni Koskela <akx@iki.fi> | 2024-01-02 15:14:05 +0000 |
---|---|---|
committer | Aarni Koskela <akx@iki.fi> | 2024-01-02 15:14:05 +0000 |
commit | 7ad6899bf987a8ee615efbcfc99562457f89cd8b (patch) | |
tree | 9a676dd4541796ef8e745969f8de94b6e67f4555 /modules/upscaler_utils.py | |
parent | 7c3ab416adae53463c16abc90acfcdd2cdd0045a (diff) | |
download | stable-diffusion-webui-gfx803-7ad6899bf987a8ee615efbcfc99562457f89cd8b.tar.gz stable-diffusion-webui-gfx803-7ad6899bf987a8ee615efbcfc99562457f89cd8b.tar.bz2 stable-diffusion-webui-gfx803-7ad6899bf987a8ee615efbcfc99562457f89cd8b.zip |
torch_bgr_to_pil_image: round, don't truncate
This matches what `realesrgan` does.
Diffstat (limited to 'modules/upscaler_utils.py')
-rw-r--r-- | modules/upscaler_utils.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/modules/upscaler_utils.py b/modules/upscaler_utils.py index e4c63f09..4f1417cf 100644 --- a/modules/upscaler_utils.py +++ b/modules/upscaler_utils.py @@ -30,7 +30,7 @@ def torch_bgr_to_pil_image(tensor: torch.Tensor) -> Image.Image: # TODO: is `tensor.float().cpu()...numpy()` the most efficient idiom? arr = tensor.float().cpu().clamp_(0, 1).numpy() # clamp arr = 255.0 * np.moveaxis(arr, 0, 2) # CHW to HWC, rescale - arr = arr.astype(np.uint8) + arr = arr.round().astype(np.uint8) arr = arr[:, :, ::-1] # flip BGR to RGB return Image.fromarray(arr, "RGB") |