ホーム AI・IT [12GB VRAM] The Complete Guide to Forging the Ultimate Character LoRA with the Next-Gen Image Generation AI "Anima"

[12GB VRAM] The Complete Guide to Forging the Ultimate Character LoRA with the Next-Gen Image Generation AI "Anima"

東條 淳平 東條 淳平 • 更新: • 公開: • 読了約 31 分
目次

Hello, this is Kamishita.

The local image generation AI, Anima base, which has been a hot topic for a while, has finally released v1.0!

Features of Anima:

  • A 2-billion parameter text-to-image generation model specialized for anime

  • Trained on millions of anime images and approximately 800,000 non-anime artworks

  • Knowledge up to September 2025

  • Supports resolutions from 512x512 to 1536x1536

  • Capable of generating adult-oriented images

It has good prompt adherence, and while it offers the flexibility of specifying tags like SDXL or using natural language (English) instructions, it can also render text specified in the prompt, albeit only in English.

Previously, a preview version was available, but now that Anima base v1.0 has been released, I tried using it in ComfyUI right away... but the images were a bit underwhelming. As you can see from the official sample images, it has a sort of anime-style coloring, but with a Showa-era feel to it.

I didn't want to use it as is, so I decided to try creating my own LoRA!

This time, I will specifically introduce a method to enjoy the benefits of Anima's prompt adherence while retaining the art style of SDXL (Illustrious)!


LoRA training environment for Anima base v1.0

nf6cb2520d2a2

When it comes to training image generation AI, there is AI-Toolkit, but I still want to recommend kohya-ss's sd-scripts. I've been using it since the SDXL era.

https://github.com/kohya-ss/sd-scripts/tree/main

It also supports LoRA training for Anima, and the README has been published.

https://github.com/kohya-ss/sd-scripts/blob/main/docs/anima_train_network.md

My PC environment is as follows. Although it is a multi-GPU setup, I am only using an RTX 4070 12GB for this.

  • OS: Windows 11 Pro (WSL2 not used)

  • CPU: Core i3 12100F

  • DRAM: DDR4 48GB

  • GPU: RTX4070 12GB + RTX3060 12GB (Multi-GPU)


Installing sd-scripts

The basics follow the official procedure, but some points require caution.

1) Download and Setup

Download sd-scripts and build the virtual environment. Install the pytorch-related components and the necessary libraries. Move on to the accelerator settings.

git clone https://github.com/kohya-ss/sd-scripts.git
cd sd-scripts

python -m venv venv
.\venv\Scripts\activate

pip install torch==2.6.0 torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cu124
pip install --upgrade -r requirements.txt

accelerate config
2) Accelerator Settings

When you run accelerate config, you will be asked various questions. Answer these as you would in the official guide, but in my multi-GPU setup at home, setting the "GPU to use" to "all" caused an error during training. I answer "0" to force it to use only the RTX4070.

- This machine
- No distributed training
- NO
- NO
- NO
- 0    <--- ここだけ公式と違う。
- fp16

Depending on the version, there might be an additional question: "Would you like to enable numa efficiency? (Currently only supported on NVIDIA hardware)", but you can answer "NO" to this as well.

3) Installing xformers

This is as per the official guide. Make sure to run it while the virtual environment is properly activated.

pip install xformers --index-url https://download.pytorch.org/whl/cu124

That completes the installation process.


Preparing images for training

First, prepare about 20 images at 1024x1024 resolution. Also, prepare a text file (caption) containing a description of the image for each image. This part is the same as training for SDXL itself.

Caution: If the resolution of your training images is low, the resulting LoRA will only generate "flat" images. I also tried making a LoRA using 12 images at 512x512 (slightly low quality, face-focused) that I had used for SDXL (illustrious noobai) training, but the results were lackluster. Even though it took 3 hours...

It is better to prepare high-definition images at 1024x1024 whenever possible. It also seems beneficial to specify the captions properly.

This time, I generated 20 images like the ones below using SDXL (illustrious) and decided to use them for Anima LoRA training. The key point is to create and prepare images in your favorite art style using SDXL, and use those.

I am the same way, but I think there is a certain number of people in the community who still use SDXL because they don't like the art style of the latest generative models. This applies to Anima as well; even if you generate images in its default state, you might not like the art style. However, you still want to try using a model with high prompt adherence. I think that dilemma exists. I felt the same way.

That is where LoRA comes in. By using images created with your favorite SDXL model as the training dataset for Anima, you can reproduce that art style and character in Anima.


As for the captions, I used the content below. I prepared one for each image. Natural language is fine, but it must be in English.

Since it is difficult to think of and create these for 20 images by yourself, let's use AI like ChatGPT to create them. I used a local LLM (LM Studio: Gemma4:26B) to create a script that automatically generates caption files.

The caption file name should be the same as the corresponding image file name. Only the extension is different, like png/jpeg/webp and txt.

Create 20 sets of these "image and caption file combinations" and place them in an appropriate folder. It is fine as long as the path does not contain Japanese characters.

Caution: Tools of this nature do not handle Japanese characters in paths well. This time, I carelessly specified "Desktop" as the output destination for the LoRA files, and after 3 hours of training, I was panicked because it displayed a folder name with garbled characters and an error output, making me worry that the save had failed.


Starting LoRA training with sd-scripts

Since sd-scripts is a CLI tool, prepare a batch file and a configuration file (toml) for training.

Training batch file: train_anima.bat

call .\venv\Scripts\activate

accelerate launch --num_cpu_threads_per_process 1 anima_train_network.py ^
  --pretrained_model_name_or_path="C:\comfyui\ComfyUI_windows_portable\ComfyUI\models\diffusion_models\anima-base-v1.0.safetensors" ^
  --qwen3="C:\comfyui\ComfyUI_windows_portable\ComfyUI\models\text_encoders\qwen_3_06b_base.safetensors" ^
  --vae="C:\comfyui\ComfyUI_windows_portable\ComfyUI\models\vae\qwen_image_vae.safetensors" ^
  --dataset_config="my_anima_dataset_config.toml" ^
  --output_dir="C:\comfyui\ComfyUI_windows_portable\ComfyUI\models\loras\sayaka_anima" ^
  --output_name="sayaka_anima_v1" ^
  --save_model_as=safetensors ^
  --network_module=networks.lora_anima ^
  --network_dim=16 ^
  --learning_rate=1e-4 ^
  --optimizer_type="AdamW8bit" ^
  --lr_scheduler="constant" ^
  --timestep_sampling="sigmoid" ^
  --discrete_flow_shift=1.0 ^
  --max_train_epochs=10 ^
  --save_every_n_epochs=1 ^
  --mixed_precision="fp16" ^
  --gradient_checkpointing ^
  --cache_latents ^
  --vae_chunk_size=64 ^
  --vae_disable_cache ^
  --max_data_loader_n_workers=0

pause

Please adjust the model paths, such as anima-base-v1, to match your own environment. Also, please change the LoRA output folder. Since output_name will be the name of the LoRA file, you can choose whatever you like.

Configuration file: my_anima_dataset_config.toml

[general]
shuffle_caption = false
caption_extension = ".txt"
keep_tokens = 0

[[datasets]]
resolution = [1024, 1024]
batch_size = 1

  [[datasets.subsets]]
  image_dir = "<学習用の画像・キャプションを置いたフォルダ>"
  num_repeats = 20

I am not certain if these settings are correct, but I was able to complete the training. Let's change the batch_size according to your hardware. In my environment (RTX4070 12GB), it wouldn't fit in VRAM with batch_size=4 and the estimated training time became 12 hours, so I set it to batch_size=1. With this, it fit within the VRAM and the training finished in about 3 hours.

Place the above two files in the top directory of sd-scripts. After that, just run train_anima.bat. If all goes well, training will begin. With the settings above and 20 training images, it will train for about 4000 steps. This should be enough training.

During training, it uses about 8.5GB of VRAM. Increasing the batch_size will increase this, and if it overflows into DRAM, the training time will increase significantly, so I recommend doing some trial and error while watching the Task Manager.

By the way, you might see triton warnings or git hash warnings along the way, but you can ignore those. As long as the training progress bar is moving, there is no problem.

Image generation with the trained LoRA

Once training is successfully completed, the LoRA (something.safetensors) will be finished, so let's place it in the models/loras/ folder within the ComfyUI folder.

The Anima ComfyUI workflow is provided by the official ComfyUI, but since the model uses the preview model in the default settings and LoRA settings were not possible, I am using a modified workflow.

You can just drop this json file into the ComfyUI browser screen. After that, just configure the model settings and LoRA settings according to your own environment. If you get an error saying nodes are missing, please install the Missing Nodes from Comfy Manager.

The LoRA setting node is inside the Text to Image (Anima) node.

For the strength_model on the left, it's a good idea to try lowering it from 1.00 depending on how effective the LoRA is. In my environment, 1.00 was fine. When using SDXL, it was common to apply LoRA at around 0.6, so let's find a good setting through trial and error here as well.

Examples using a self-made LoRA

The following are examples using Anima base v1.0 with my self-made LoRA. I will compare them with and without the LoRA applied.

A woman standing among hydrangeas

The art style is quite different, isn't it? The LoRA is having a significant effect.

Office lady with a ponytail

I think you can see the difference in art style more clearly than in the previous example. The left side is the art style of Anima base v1.0 as is, which leans towards anime. You might be able to change the art style a bit more by tweaking the prompt, but it's easier to just create a LoRA that you like.

Woman taking a break at a cafe

The impression here is also quite different depending on whether LoRA is used or not. Since the composition is the same, you can see that while maintaining the prompt adherence of Anima base v1.0, the art style and character of SDXL (illustrious) have been successfully ported using a custom LoRA.

Like this, for those who have been hesitant to migrate from SDXL to the latest image generation models,

  1. 20 images of 1024x1024 created with your favorite generation model

  2. Use those to create a LoRA for the migration target model

By doing this, you can continue to use your favorite art style and characters while enjoying the benefits of the high prompt adherence of the latest models!

Bonus

As a bonus, I also tried a prompt that seemed difficult for SDXL.

The smartphone in the left hand is NG (it's held in the right hand), but everything else is OK.


Although it is holding the cake plate instead of the glass with its left hand, the color separation of the outfit is perfect. The cat is cute.


Like this, even for content that SDXL might not follow the prompt for as well, it generates with high accuracy. Of course, hands and fingers can still get weird with Anima, so the gacha element remains.

Summary

  • Trained a LoRA on Anima base v1.0 using sd-scripts

  • Successfully ported my favorite SDXL art style to Anima

  • Was able to train it in 3 hours even on a 12GB VRAM graphics card

Personally, I had passed on Qwen Image and Z-Image because there were no image generation models that could reproduce my SDXL art style, but if I can port art styles and characters to the latest image generation models using custom LoRAs like this, the hurdle for migration seems lower!

Thank you for reading until the end!

If you felt this article was "helpful" or "provided development hints," pressing the [Like (heart mark)] at the bottom of the screen would be so encouraging that it would blow away the hardships of verification!

I will continue to publish gritty technical verification and work efficiency workflows, so following would also be greatly appreciated!



同じカテゴリの記事

東條 淳平

スポーツと芸能が交差する話題を担当。大会公式記録と所属先の発表を突き合わせ、数字は必ず出典付きで扱います。

おすすめの関連記事