docs/getting-started: tweak toc and update snippet

`encode_image` has been deprecated part of #213
This commit is contained in:
Cédric Deltheil 2024-02-02 12:50:41 +00:00 committed by Cédric Deltheil
parent 7b8e9e3c67
commit 17046e0717

View file

@ -8,7 +8,7 @@ Refiners is still a young project and development is active, so to use the lates
Moreover, we recommend using [Rye](https://rye-up.com) which simplifies several things related to Python package management, so start by following the instructions to install it on your system. Moreover, we recommend using [Rye](https://rye-up.com) which simplifies several things related to Python package management, so start by following the instructions to install it on your system.
## Trying Refiners, converting weights ## Installing
To try Refiners, clone the GitHub repository and install it with all optional features: To try Refiners, clone the GitHub repository and install it with all optional features:
@ -18,13 +18,18 @@ cd refiners
rye sync --all-features rye sync --all-features
``` ```
## Converting weights
The format of state dicts used by Refiners is custom and we do not redistribute model weights, but we provide conversion tools and working scripts for popular models. For instance, let us convert the autoencoder from Stable Diffusion 1.5: The format of state dicts used by Refiners is custom and we do not redistribute model weights, but we provide conversion tools and working scripts for popular models. For instance, let us convert the autoencoder from Stable Diffusion 1.5:
```bash ```bash
python "scripts/conversion/convert_diffusers_autoencoder_kl.py" --to "lda.safetensors" python "scripts/conversion/convert_diffusers_autoencoder_kl.py" --to "lda.safetensors"
``` ```
If you need to convert weights for all models, check out `script/prepare_test_weights.py` (warning: it requires a GPU with significant VRAM and a lot of disk space). If you need to convert weights for all models, check out `script/prepare_test_weights.py`.
!!! warning
Using `script/prepare_test_weights.py` requires a GPU with significant VRAM and a lot of disk space.
Now to check that it works copy your favorite 512x512 picture in the current directory as `input.png` and create `ldatest.py` with this content: Now to check that it works copy your favorite 512x512 picture in the current directory as `input.png` and create `ldatest.py` with this content:
@ -38,8 +43,8 @@ with no_grad():
lda.load_from_safetensors("lda.safetensors") lda.load_from_safetensors("lda.safetensors")
image = Image.open("input.png") image = Image.open("input.png")
latents = lda.encode_image(image) latents = lda.image_to_latents(image)
decoded = lda.decode_latents(latents) decoded = lda.latents_to_image(latents)
decoded.save("output.png") decoded.save("output.png")
``` ```
@ -51,7 +56,7 @@ python ldatest.py
Inspect `output.png`: it should be similar to `input.png` but have a few differences. Latent Autoencoders are good compressors! Inspect `output.png`: it should be similar to `input.png` but have a few differences. Latent Autoencoders are good compressors!
## Using refiners in your own project ## Using Refiners in your own project
So far you used Refiners as a standalone package, but if you want to create your own project using it as a dependency here is how you can proceed: So far you used Refiners as a standalone package, but if you want to create your own project using it as a dependency here is how you can proceed:
@ -70,7 +75,8 @@ To convert weights, you can either use a copy of the `refiners` repository as de
rye add --dev --git "git@github.com:finegrain-ai/refiners.git" --features conversion refiners rye add --dev --git "git@github.com:finegrain-ai/refiners.git" --features conversion refiners
``` ```
Note that you will still need to download the conversion scripts independently if you go that route. !!! note
You will still need to download the conversion scripts independently if you go that route.
## What's next? ## What's next?