
Easy Guide to make a LoRA for Flux
Hello, my friends?Many of you already know how to create LoRAs. And there are many articles about creating a LoRA on this site. However, I just wanted to add another tutorial for whoever wants to check it from my creation process. Let's begin! I'll use many images I captured during the creation process. (Please let me know if you find any mistakes here~)Step 1. upload imagesWell, before uploading images, you need to prepare for the images first of course. For Flux LoRA of a character, it'll be somewhere from 15 ~ 40 probably. For this tutorial, I prepared for only 12 images. The image quality of the images is not really ideal either. We'd better have a very high quality images of various angles. You'd better not use images of poor quality. It only makes your result worse. For Flux, well, you can use OK images because Flux is very smart to learn and create a good LoRA under harsh circumstances.If you go to the online training menu on the top of Tensor Art site and click it, you'll see a screen like the following. You click the upload images button in the left empty area, a pop up window will show up. Then you can go to the folder of your stored images and select them. Then, they will show up on the training window like the following image. If you click on any of the images there, another window will pop up to show the image and the caption (tag) created for it. (When the image is uploaded, the tool will generate the caption of the images automatically. You can create your own caption file and upload it with each image if you want. Let's skip it for now.)Step 2. Parameter SettingsNext, check the parameters for the training correctly as follows. Make sure you are in pro mode. If you click the button on the right top, it will change to "Basic Mode" button as follows. Click the SD3/Flux Standard check box. Then use base model of Flux.1 which is a default. For Network Module, change it to LoKr instead of LoRA. They are similar things. Personally, I prefer LoKr. Please ask ChatGPT for details about them, and teach me too~ LOL.For the primary trigger words, use proper words with under scores like ek_sku11_kn1ght used in my case. I used 1's to replace certain alphabet letters like 'l' and 'i'. Why? I was told to use words not to be confused with any other "normal" prompt words. I might not be correct about this. For other additional trigger words, you can use normal phrases you want to use for the LoRA. These trigger words are usually used during your train process as caption to teach the LoRA about the images.Fo example, if you want to teach the "metallic surface", then it must be in the caption of the right images. Then the LoRA will learn the image's metallic surface. When you generate an image using your LoRA later, if you use the trigger words "metallic surface", the related image result will show up better probably. That's what I understand so far. I might be wrong in many details. Don't trust me 100%. 🤗😉 At the bottom, the amount of credits used for LoRA creation is shown. It's 210.61 credits. However, it's for the default settings of repeat: 20 and epoch:10. We will use less numbers for the training this time and the credits will reduce a lot.Let's continue to the next steps. For the "Skull Knight" LoRA I'm trying to make now, I don't really need a complete match to the original source images. I just want an OK Skull Knight for my K-Wonder Women story making~ LOL. So I reduce the repeat down to 15 and epoch down to 3. If the result is bad, we can continue the training process from the epoch 3 later. (However, this continuation of training is only available for Pro users unfortunately.) Save every N Epochs is set to 1 which means you want to save the generated lora called safetensors at every epoch. You don't know where in the training process you will get the best result until you see the sample results. So you need to save the result at every epoch.The desirable resolution for Flux Lora training is 1024x1024. However, you can still get the result of certain quality by choosing 512x512. For serious Lora creation like a beautiful woman's face, I use 1024x1024 of course. For this kind of OK Lora, I can try 512x512. The credits are saved a lot by choosing smaller image size here. Check out the credits at the bottom now. It's only 47.39!! BTW, your source images are supposed to be prepared matching this resolution at first. (To be honest, you can use various resolutions for the source images and the training still works. However, for the best training result, you are supposed to use the correct source image size for training. Don't blame me later. 🤗)Step 3. Parameter Setting (2)The parameter setting is too long and I break it into several steps. Check the numbers in the following image and just use them if you are not sure what to do here. For LR scheduler I prefer cosine_with_restarts. However other scheduler like "constant" or "linear" will work fine too. For details, ask chatGPT and teach me later too~ lol. For optimizer, AdamW8bit is used. There are other choices here too. Ask ChatGPT~.Shuffle caption is set to enabled. Keep N tokens is 1 because we will put the primary trigger word at the beginning of the captions later. Then the Lora doesn't check the trigger word as part of caption. For noise offset and other numbers use the default. Some articles say that the noise offset should be 0.0357. According to my experience, the default 0.03 is still OK. I couldn't tell the difference in the final results in many cases. For conv_dim, use 4. For conv_alpha, use 1. These numbers are very important. For style LoRAs, we use different settings like 8 and 2 here.Step 4. Parameter Setting (3)For sample image generation during the training, use proper prompt. However, don't use complicated prompt words as you do in the real generation later. Make it simple to check the effect of the Loras more easily. Check the prompt I used here for example. Include the trigger words in the prompt. Set the image size of the sample images as you wish. I checked 768 x 1024 here. For sampler, use Euler or Euler_ancestral. For pro users, click the Priority Queue button for faster training process.Step 5. Add trigger words in captionYou need to put the primary trigger word in the beginning of your captions. Use the labeling menu and put the trigger word at the beginning as follows.Now you can see that the primary trigger word is placed at the beginning of the captions in every image. You cannot do this manually one by one. (Well, you can do it if you have the caption as a separate file from the beginning.)For additional trigger words, you can put them in the end as follows. I have another trigger words "Skull Knight" which is not really necessary but I used it for the tutorial.Now, the new trigger words are in the end of your caption of every image.Now select the Priority Queue button. Then press "Start Training Now" button.Step 6. Training starts...Now a new window pops up as follows. The name of the training session is shown as a time stamp. You can change the name of the session as follows. Select "rename" on the right top menu.Change it to the name you want. I put "skull knight 1.0". BTW, this name becomes the version name of your lora after you publish it later. I usually change them to the real version number like 0.5 or 1.0 or 2.0 later. We can edit it later. Don't worry.Step 7. Training ProgressYou can select the parameter setting menu and check if everything is OK here. If you find out any mistakes, you can stop the training before it starts and save your credits. (BTW, I asked TA to make this cancel feature long ago. They accepted my suggestion. Yeah, you owe me a big one~ LOL.)As the training progresses, you'll see that the "Loss" is getting lower (sometimes it goes up and down). You see the result of every epoch from the 4 sample images. Click and see the images if they are what you want. You can compare the sample images of different epochs. You can choose the epoch with best sample results of your favorite for publication. The "publish" button at the bottom of each epoch can be used to publish the corresponding epoch's safetensors. The continue button at each epoch can be used when you want to continue another session of training starting from the epoch. This is really convenient thanks to TA. Great Job, TA~You can see that the image of the same location of the samples improved as the epochs change.Step 8. Publish your LoRA.OK. The training is over and you are happy with your sample results. Then publish it as your LoRA project! Easy huh? The following window pops up. Click the "+ Create a project" menu. You could have created a project separately from TA's home page before.Add project name and select the channel and tags properly.Add description for the LoRA you just created. In 2, you can see your session name as Model Version. If you want, you can change it to a different number or name you want. You can edit this later too.Set the default LoRA strength you want. I set 0.8 here.You can add more showcase images here. You will come back here to make changes later after you generate images using your Lora.Choose Download enabled or prohibited here. I chose "prohibited". Then press "Publish" button.Then, project edit page will pop up. Type in the project name you want. Select the tags you want.Add description for your LoRA project. Select Original or Original - Exclusive depending on your preferences. Early Access is not used any more. Select the remaining choices and press "Update" and you are all set~ Good luck!Step 9. Using the created LoRAThe final results are not very bad~. From the small set of images and 512x512, we still got a decent LoRA!Step 10. Continued TrainingTo improve LoRA, I continued the training up to epoch 7. I added more captions/trigger words related to spikes as follows. The result improved to be close to the original source images. Thanks for reading! 🤗😉
