dn6 HF Staff commited on
Commit
5378204
·
verified ·
1 Parent(s): e6d2e0a

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +1 -19
README.md CHANGED
@@ -57,28 +57,10 @@ recon_image.save("reconstituted.png")
57
 
58
  ```py
59
  import torch
60
- import torchvision.transforms.functional as F
61
  from diffusers import AutoModel
62
- from diffusers.utils import load_image
63
 
64
  device = torch.device("cuda")
65
  tiny_vae = AutoModel.from_pretrained(
66
- "fal/FLUX.2-Tiny-AutoEncoder",
67
- trust_remote_code=True,
68
- torch_dtype=torch.bfloat16
69
  ).to(device)
70
-
71
- pil_image = load_image("/path/to/image.png")
72
- image_tensor = F.to_tensor(pil_image)
73
- image_tensor = image_tensor.unsqueeze(0) * 2.0 - 1.0
74
- image_tensor = image_tensor.to(device, dtype=tiny_vae.dtype)
75
-
76
- with torch.inference_mode():
77
- latents = tiny_vae.encode(image_tensor, return_dict=False)
78
- recon = tiny_vae.decode(latents, return_dict=False)
79
- recon = recon.squeeze(0).clamp(-1, 1) / 2.0 + 0.5
80
- recon = recon.float().detach().cpu()
81
-
82
- recon_image = F.to_pil_image(recon)
83
- recon_image.save("reconstituted.png")
84
  ```
 
57
 
58
  ```py
59
  import torch
 
60
  from diffusers import AutoModel
 
61
 
62
  device = torch.device("cuda")
63
  tiny_vae = AutoModel.from_pretrained(
64
+ "fal/FLUX.2-Tiny-AutoEncoder", trust_remote_code=True, torch_dtype=torch.bfloat16
 
 
65
  ).to(device)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  ```