Update README.md
Browse files
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 [
|
| 78 |
def postprocess_tensor(tensor):
|
| 79 |
-
tensor = torch.clamp(tensor,
|
|
|
|
| 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.
|