[Textual Inversion](https://hf.co/papers/2208.01618) is a training technique for personalizing image generation models with just a few example images of what you want it to learn. This technique works by learning and updating the text embeddings (the new embeddings are tied to a special word you must use in the prompt) to match the example images you provide.  
If you're training on a GPU with limited vRAM, you should try enabling the `gradient_checkpointing` and `mixed_precision` parameters in the training command. You can also reduce your memory footprint by using memory-efficient attention with [xFormers](../optimization/xformers). JAX/Flax training is also supported for efficient training on TPUs and GPUs, but it doesn't support gradient checkpointing or xFormers. With the same configuration and setup as PyTorch, the Flax training script should be at least ~70% faster!  
This guide will explore the [textual_inversion.py](https://github.com/huggingface/diffusers/blob/main/examples/textual_inversion/textual_inversion.py) script to help you become more familiar with it, and how you can adapt it for your own use-case.  
Before running the script, make sure you install the library from source:  
```bash
git clone https://github.com/huggingface/diffusers
cd diffusers
pip install .
```  
Navigate to the example folder with the training script and install the required dependencies for the script you're using:  
<hfoptions id="installation">
<hfoption id="PyTorch">  
```bash
cd examples/textual_inversion
pip install -r requirements.txt
```  
</hfoption>
<hfoption id="Flax">  
```bash
cd examples/textual_inversion
pip install -r requirements_flax.txt
```  
</hfoption>
</hfoptions>  
<Tip>  
🤗 Accelerate is a library for helping you train on multiple GPUs/TPUs or with mixed-precision. It'll automatically configure your training setup based on your hardware and environment. Take a look at the 🤗 Accelerate [Quick tour](https://huggingface.co/docs/accelerate/quicktour) to learn more.  
</Tip>  
Initialize an 🤗 Accelerate environment:  
```bash
accelerate config
```  
To setup a default 🤗 Accelerate environment without choosing any configurations:  
```bash
accelerate config default
```  
Or if your environment doesn't support an interactive shell, like a notebook, you can use:  
```py
from accelerate.utils import write_basic_config

write_basic_config()
```  
Lastly, if you want to train a model on your own dataset, take a look at the [Create a dataset for training](create_dataset) guide to learn how to create a dataset that works with the training script.  
<Tip>  
The following sections highlight parts of the training script that are important for understanding how to modify it, but it doesn't cover every aspect of the script in detail. If you're interested in learning more, feel free to read through the [script](https://github.com/huggingface/diffusers/blob/main/examples/textual_inversion/textual_inversion.py) and let us know if you have any questions or concerns.  
</Tip>
/Users/nielsrogge/Documents/python_projecten/diffusers/docs/source/en/training/text_inversion.md