mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-22 12:20:16 +08:00
clamp needed to change to match
This commit is contained in:
parent
1fd5f330a8
commit
b3fb40adb8
@ -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
|
# but we don't care about it blocking because the main stream is fine
|
||||||
preview_image = preview_image.cpu()
|
preview_image = preview_image.cpu()
|
||||||
|
|
||||||
|
preview_image.clamp_(-1.0, 1.0)
|
||||||
preview_image.add_(1.0)
|
preview_image.add_(1.0)
|
||||||
preview_image.mul_(127.5)
|
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
|
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())
|
return Image.fromarray(preview_image.to(dtype=torch.uint8).numpy())
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user