description: <p>Updates will be mirrored on both Hugging Face and Civitai.</p><h2>Introduction</h2><p><a target="_blank" rel="ugc" href="https://civitai.com/models/23476/the-idolmster-cinderella-girls-starlight-stage-style-90-characters"><strong>It has been shown that multiple characters can be trained into the same model</strong></a>. A harder task is to create a model that can generate multiple characters simultaneously without modifying the generation pipeline. This document describes a simple technique that has been shown to help generating multiple characters in the same image.</p><h2>Method</h2><pre><code>Requirement: Sets of single-character images
  Steps:
  1. Train a multi-concept model using the original dataset
  2. Create an augmentation dataset of joined image pairs (composites) from the original dataset
  3. Train on the augmentation dataset
  </code></pre><h2>Experiment</h2><h3>Setup</h3><p>3 characters from the game Cinderella Girls are chosen for the experiment. The base model is <code>anime-final-pruned</code>. It has been checked that the base model has minimal knowledge of the trained characters. Images with multiple characters were removed (edit: after training it was found that some unrelated background characters were not removed).</p><p>For the captions of the joined images, the template format <code>CharLeft/CharRight/COMPOSITE, TagsLeft, TagsRight</code> is used.</p><p>A LoRA (Hadamard product) is trained using the config file below:</p><pre><code>[model_arguments]
  v2 = false
  v_parameterization = false
  pretrained_model_name_or_path = "Animefull-final-pruned.ckpt"
  
  [additional_network_arguments]
  no_metadata = false
  unet_lr = 0.0005
  text_encoder_lr = 0.0005
  network_module = "lycoris.kohya"
  network_dim = 8
  network_alpha = 1
  network_args = [ "conv_dim=0", "conv_alpha=16", "algo=loha",]
  network_train_unet_only = false
  network_train_text_encoder_only = false
  
  [optimizer_arguments]
  optimizer_type = "AdamW8bit"
  learning_rate = 0.0005
  max_grad_norm = 1.0
  lr_scheduler = "cosine"
  lr_warmup_steps = 0
  
  [dataset_arguments]
  debug_dataset = false
  # keep token 1
  # resolution 640*640
  
  [training_arguments]
  output_name = "cg3comp"
  save_precision = "fp16"
  save_every_n_epochs = 1
  train_batch_size = 4
  max_token_length = 225
  mem_eff_attn = false
  xformers = true
  max_train_epochs = 40
  max_data_loader_n_workers = 8
  persistent_data_loader_workers = true
  gradient_checkpointing = false
  gradient_accumulation_steps = 1
  mixed_precision = "fp16"
  clip_skip = 2
  lowram = true
  
  [sample_prompt_arguments]
  sample_every_n_epochs = 1
  sample_sampler = "k_euler_a"
  
  [saving_arguments]
  save_model_as = "safetensors"
  </code></pre><p>For the second stage of training, the batch size was reduced to 2 and the resolution was set to 768 * 768 while keeping other settings identical. The training took less than 2 hours on a T4 GPU.</p><h3>Results</h3><p>(see preview images)</p><h2>Limitations</h2><ul><li><p>This technique doubles the memory/compute requirement</p></li><li><p>Composites can still be generated despite negative prompting</p></li><li><p>Cloned characters seem to become the primary failure mode in place of blended characters</p></li><li><p>Can generate 2 characters but not 3 for some reason</p></li></ul><h2>Related Works</h2><p>Models been trained on datasets based on anime shows have <a target="_blank" rel="ugc" href="https://civitai.com/models/21305/"><strong>demonstrated</strong></a> multi-subject capability. Simply using concepts distant enough such as <code>1girl, 1boy</code> <a target="_blank" rel="ugc" href="https://civitai.com/models/17640/"><strong>has also been shown to be effective</strong></a>.</p><h2>Future work</h2><p>Below is a list of ideas yet to be explored</p><ul><li><p>Synthetic datasets</p></li><li><p>Unequal aspect ratios</p></li><li><p>Regularization</p></li><li><p>Joint training instaed of sequential</p></li></ul>
modelVersions.availability: Public
modelVersions.baseModel: SD 1.5
modelVersions.baseModelType: Standard
modelVersions.downloadUrl: https://civitai.com/api/download/models/35902
modelVersions.downloaded: true
modelVersions.downloadUrl: https://civitai.com/api/download/models/35902
modelVersions.AutoV1: 1F3146FE
modelVersions.AutoV2: 10F79BDC6F
modelVersions.AutoV3: FFA703813B8E
modelVersions.BLAKE3: 7837CFE4A58A26F644F113F25C588BFF2B3896AAFAADE3F9DF1043AAD2D50AA0
modelVersions.CRC32: F9DD79C1
modelVersions.SHA256: 10F79BDC6F4F1BE7A5232BEA94A159C7BC6A4DE7E8C2965E0819878D14B2EC81
modelVersions.format: SafeTensor
modelVersions.name: cg3comp.safetensors
modelVersions.pickleScanMessage: No Pickle imports
modelVersions.pickleScanResult: Success
modelVersions.scannedAt: 2023-04-04T14:21:06.651Z
modelVersions.type: Model
modelVersions.virusScanResult: Success
modelVersions.hash: UeOput~q?b-:-pRjRkjZo2WVfkjYxuafofWX
modelVersions.type: image
modelVersions.url: https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/716f32b7-dcf0-4743-74cf-3bb267b6ce00/width=450/416650.jpeg
modelVersions.hash: UaON2pRmV@jE~SR.R.W=_3xtxaxuOuV?WUNG
modelVersions.type: image
modelVersions.url: https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/05dd9c90-69a2-4c11-69ed-266a7eaec300/width=450/416659.jpeg
modelVersions.hash: UZPPipNfWn9u~of5WV$P%h%0s:t6yYRjRjW-
modelVersions.type: image
modelVersions.url: https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/d7e0bc57-000a-4644-746e-90c50818e900/width=450/416667.jpeg
modelVersions.name: v1.0
modelVersions.publishedAt: 2023-04-04T14:16:26.988Z
name: Guide: 1to2: Training Multiple-Subject Models using only Single-Subject Data (Experimental)
tags: guide