# How to train a FLUX.1 LoRA [[FLUX.1]] is open-source, which makes it possible to train customized variants easily, also known as [[Low Rank Adapter (LoRA)]]. Various "trainers" can be found online. ## Tutorial using Replicate.com I've experimented with training custom models through [[Replicate.com]], using the following steps. ### Prepare the training images First, collect 15+ pictures of the person (or "thing") you want to create a custom model for. Then, rename those pictures using a systematic naming convention such as `a_photo_of_name (01).jpg`. The `name` should be replaced by the keyword you want to use in your image generation prompts. Here's an example of how it should look: ![[How to train a FLUX.1 LoRA - example folder.png]] Once the pictures are ready, create a zip file containing those (cfr first file in the example above) ### Create an account on HuggingFace Go to [[HuggingFace]], and create an account if you don't have one yet. ### Create a model on HuggingFace Now, create a new model on the following page: https://huggingface.co/new. I chose to call mine `flux-lora-dsebastien`. The model can be public or private, it doesn't matter (apart for privacy reasons). ### Create a HuggingFace access token Now, go to the following page to create a new HuggingFace access token: https://huggingface.co/settings/tokens/new?tokenType=fineGrained Adapt the settings as follows: ![[How to train a FLUX.1 LoRA - hf access token config.png]] Create the token, and write it down. That token will be used by [[Replicate.com]] to save your model once trained. ### Train your new model on Replicate Go to the following page to train your model: https://replicate.com/ostris/flux-dev-lora-trainer/train. Use the following settings. In the `destination` field, click on the dropdown, then on `Create a new model`: ![[How to train a FLUX.1 LoRA - replicate - create new model.png]] I chose to call mine: `flux-lora-dsebastien` (same as on [[HuggingFace]]). Then, under `input_images`, select and upload the zip file you have prepared earlier. Under `trigger_word`, make sure to choose a specific keyword. You will use it in your prompt to refer to trained person or "thing". In my case, I again chose `dsebastien` for consistency. Under `hf_repo_id`, enter the path to the model you have created on [[HuggingFace]]. In my case: `dsebastien/flux-lora-dsebastien`. Finally, under `hf_token`, enter the [[HuggingFace]] token you have created. Now click on `Create training`, and go drink a cup of tea. Your LoRA will be trained. It will take a while (~20-60 minutes). Once created, your model will be published on HuggingFace, and will be accessible in your list of models on [[Replicate.com]]: https://replicate.com/models. Now, you should be able to generate your own customized images, such as the one below, using [[Replicate.com]] or other means. ![[seb-panda.png]] Enjoy! 🎉 ## References - Trainer: https://replicate.com/ostris/flux-dev-lora-trainer/train - Replicate blog post: https://replicate.com/blog/fine-tune-flux - Video tutorial: https://www.youtube.com/watch?v=_rjto4ix3rA ## Related - [[FLUX.1]] - [[Combining multiple LoRAs]] - [[Low Rank Adapter (LoRA)]]