Diffusers
Safetensors
English
vae
convolutional
generative
fquattrini commited on
Commit
5b03f74
·
verified ·
1 Parent(s): 8259474

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +3 -2
README.md CHANGED
@@ -58,16 +58,17 @@ import torch
58
  from PIL import Image
59
  from diffusers import AutoencoderKL
60
  from huggingface_hub import hf_hub_download
61
- from torchvision.transforms.functional import to_tensor, to_pil_image
62
 
63
  # Load the pre-trained Emuru VAE from Hugging Face Hub.
64
  model = AutoencoderKL.from_pretrained("blowing-up-groundhogs/emuru_vae")
65
 
66
  # Function to preprocess an RGB image:
67
- # Loads the image, converts it to RGB, and transforms it to a tensor normalized to [0, 1].
68
  def preprocess_image(image_path):
69
  image = Image.open(image_path).convert("RGB")
70
  image_tensor = to_tensor(image).unsqueeze(0) # Add batch dimension
 
71
  return image_tensor
72
 
73
  # Function to postprocess a tensor back to a PIL image for visualization:
 
58
  from PIL import Image
59
  from diffusers import AutoencoderKL
60
  from huggingface_hub import hf_hub_download
61
+ from torchvision.transforms.functional import to_tensor, to_pil_image, normalize
62
 
63
  # Load the pre-trained Emuru VAE from Hugging Face Hub.
64
  model = AutoencoderKL.from_pretrained("blowing-up-groundhogs/emuru_vae")
65
 
66
  # Function to preprocess an RGB image:
67
+ # Loads the image, converts it to RGB, and transforms it to a tensor normalized to [-1, 1].
68
  def preprocess_image(image_path):
69
  image = Image.open(image_path).convert("RGB")
70
  image_tensor = to_tensor(image).unsqueeze(0) # Add batch dimension
71
+ image_tensor = normalize(image_tensor, [0.5], [0.5])
72
  return image_tensor
73
 
74
  # Function to postprocess a tensor back to a PIL image for visualization: