clamp needed to change to match

This commit is contained in:
drhead 2025-05-25 11:19:49 -04:00 committed by GitHub
parent 1fd5f330a8
commit b3fb40adb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,9 +22,9 @@ def preview_to_image(preview_image: torch.Tensor):
# but we don't care about it blocking because the main stream is fine
preview_image = preview_image.cpu()
preview_image.clamp_(-1.0, 1.0)
preview_image.add_(1.0)
preview_image.mul_(127.5)
preview_image.clamp_(0, 1) # change scale from -1..1 to 0..1 and clamp
preview_image.round_() # default behavior when casting is truncate which is wrong for image processing
return Image.fromarray(preview_image.to(dtype=torch.uint8).numpy())