Diffusers
Safetensors
English
vae
convolutional
generative
fquattrini commited on
Commit
e85886c
·
verified ·
1 Parent(s): d645f4c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +3 -2
README.md CHANGED
@@ -74,9 +74,10 @@ def preprocess_image(image_path):
74
  return image_tensor
75
 
76
  # Function to postprocess a tensor back to a PIL image for visualization:
77
- # Clamps the tensor to [0, 1] and converts it to a PIL image.
78
  def postprocess_tensor(tensor):
79
- tensor = torch.clamp(tensor, 0, 1).squeeze(0) # Remove batch dimension
 
80
  return to_pil_image(tensor)
81
 
82
  # Example: Encode and decode an image.
 
74
  return image_tensor
75
 
76
  # Function to postprocess a tensor back to a PIL image for visualization:
77
+ # Clamps the tensor to [-1, 1] and converts it to a PIL image.
78
  def postprocess_tensor(tensor):
79
+ tensor = torch.clamp(tensor, -1, 1).squeeze(0) # Remove batch dimension
80
+ tensor = (tensor + 1) / 2
81
  return to_pil_image(tensor)
82
 
83
  # Example: Encode and decode an image.