Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev(narugo): narugo's workflow code #67

Draft
wants to merge 43 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
295a352
dev(narugo): update anime character train cfg
narugo1992 Oct 30, 2023
d36a332
dev(narugo): fix a bug on ref file
narugo1992 Oct 30, 2023
824d684
Merge branch 'main' of narugo.github.com:7eu7d7/HCP-Diffusion into main
narugo1992 Oct 30, 2023
89c836b
dev(narugo): change back to 1000 steps
narugo1992 Oct 30, 2023
0f3064c
dev(narugo): add meta information of a1111 webui
narugo1992 Oct 31, 2023
460d8bc
dev(narugo): tiny update
narugo1992 Oct 31, 2023
babc75e
dev(narugo): extend form reg config
narugo1992 Oct 31, 2023
5fff900
dev(narugo): update reg config
narugo1992 Nov 1, 2023
c3500cd
dev(narugo): use better infer cfg
narugo1992 Nov 1, 2023
d75b564
dev(narugo): use ratio bucket
narugo1992 Nov 2, 2023
9fca38d
dev(narugo): change back to ratio bucket
narugo1992 Nov 2, 2023
20f1865
dev(narugo): fix bug on sampler inference && fix some problems on sdx…
narugo1992 Nov 2, 2023
d0c9977
Merge branch 'main' of narugo.github.com:7eu7d7/HCP-Diffusion into main
narugo1992 Nov 3, 2023
61a4b69
dev(narugo): fix some problems
narugo1992 Nov 3, 2023
8da458a
dev(narugo): add output_dir for simple anime image creating
narugo1992 Nov 4, 2023
9532049
Merge branch 'workflow' of narugo.github.com:7eu7d7/HCP-Diffusion int…
narugo1992 Nov 9, 2023
4d4b5ed
Merge branch 'main' of narugo.github.com:7eu7d7/HCP-Diffusion into main
narugo1992 Nov 9, 2023
c6b8ab7
dev(narugo): add workflow for anime
narugo1992 Nov 9, 2023
52c8f43
Merge branch 'workflow' of narugo.github.com:7eu7d7/HCP-Diffusion int…
narugo1992 Nov 12, 2023
eaa9e7c
dev(narugo): add multiple script
narugo1992 Nov 12, 2023
412743a
dev(narugo): add highres script for anime
narugo1992 Nov 12, 2023
065e12f
dev(narugo): add highres workflow for sdxl
narugo1992 Nov 12, 2023
319d43a
dev(narugo): add highres workflow for sdxl
narugo1992 Nov 12, 2023
afb55c4
Merge branch 'workflow' of narugo.github.com:7eu7d7/HCP-Diffusion int…
narugo1992 Nov 13, 2023
4f98e80
dev(narugo): add lora workflow
narugo1992 Nov 13, 2023
21a801f
dev(narugo): no mask for loras
narugo1992 Nov 13, 2023
c28178b
Merge branch 'dev' into workflow
narugo1992 Dec 5, 2023
92cd20e
dev(narugo): update cfgs
narugo1992 Dec 5, 2023
102db69
dev(narugo): merge from dev
narugo1992 Dec 7, 2023
0027fcb
Merge branch 'dev' into workflow
narugo1992 Dec 7, 2023
1e225f2
dev(narugo): add highres for loras
narugo1992 Dec 7, 2023
e50bb60
dev(narugo): merge from main
narugo1992 Dec 16, 2023
d0471aa
dev(narugo): merge from main branch
narugo1992 Dec 16, 2023
3b25af6
dev(narugo): fix this
narugo1992 Jan 19, 2024
aa30bf5
dev(narugo): optimize runner file
narugo1992 Jan 19, 2024
10b261b
dev(narugo): fix it
narugo1992 Jan 19, 2024
12d1223
dev(narugo): add v1.5 training script
narugo1992 Jan 21, 2024
15a0592
dev(narugo): bug fix
narugo1992 Jan 21, 2024
2984524
dev(narugo): save it
narugo1992 Jan 22, 2024
3cf432b
dev(narugo): fix dependency problems
narugo1992 Jan 22, 2024
e4010f1
dev(narugo): update
narugo1992 Jan 23, 2024
d029331
dev(narugo): update
narugo1992 Jan 23, 2024
d0cabfc
dev(narugo): final version of trainer
narugo1992 Jan 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions cfgs/infer/anime/text2img_anime.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_base_: [cfgs/infer/text2img.yaml]
_base_: [ cfgs/infer/text2img.yaml ]

pretrained_model: 'deepghs/animefull-latest' # animefull-latest model
prompt: 'masterpiece, best quality, 1girl, solo, tohsaka rin' # image of 远坂凛(tohsaka rin)
Expand All @@ -13,9 +13,25 @@ infer_args:
num_inference_steps: 30 # how many steps

new_components:
scheduler:
_target_: diffusers.EulerAncestralDiscreteScheduler # change Sampler
# scheduler: # Euler a
# _target_: diffusers.EulerAncestralDiscreteScheduler # change Sampler
# beta_start: 0.00085
# beta_end: 0.012
# beta_schedule: 'scaled_linear'
scheduler: # DPM++ 2M Karras
_target_: diffusers.DPMSolverMultistepScheduler
beta_start: 0.00085
beta_end: 0.012
beta_schedule: 'scaled_linear'
algorithm_type: dpmsolver++
beta_schedule: scaled_linear
use_karras_sigmas: true
vae: # use NAI's vae
_target_: diffusers.AutoencoderKL.from_pretrained
pretrained_model_name_or_path: deepghs/animefull-latest # path to vae model
subfolder: vae

output_dir: 'output/'
interface:
- _target_: hcpdiff.vis.DiskInterface
show_steps: 0
save_root: '${output_dir}'
1 change: 1 addition & 0 deletions cfgs/infer/anime/text2img_anime_lora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ exp_dir: 'exps/2023-07-26-01-05-35' # experiment directory
model_steps: 1000 # steps of selected model
emb_dir: '${exp_dir}/ckpts/'
output_dir: 'output/'
encoder_attention_mask: false

merge:
alpha: 0.85 # lora权重, default: 0.85
Expand Down
26 changes: 26 additions & 0 deletions cfgs/infer/anime/text2img_sdxl_anime.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
_base_: [ cfgs/infer/text2img_sdxl.yaml ]

pretrained_model: 'KBlueLeaf/kohaku-xl-beta7.1' # base model created by kohaku
prompt: 'masterpiece, best quality, 1girl, solo, tohsaka rin' # image of 远坂凛(tohsaka rin)
neg_prompt: 'bad anatomy, disembodied limb, realistic, blurry, watercolor'

clip_skip: 1 #动漫模型通常会跳过一个CLIP层

infer_args:
width: 1024
height: 1536 # image size
guidance_scale: 7.5 # scale, when higher, the images will tend to be more similar
num_inference_steps: 30 # how many steps

new_components:
scheduler: # DPM++ 2M Karras
_target_: diffusers.DPMSolverMultistepScheduler
beta_start: 0.00085
beta_end: 0.012
algorithm_type: dpmsolver++
beta_schedule: scaled_linear
use_karras_sigmas: true
vae: # use sdxl-base-v1.0's vae
_target_: diffusers.AutoencoderKL.from_pretrained
pretrained_model_name_or_path: stabilityai/stable-diffusion-xl-base-1.0 # path to vae model
subfolder: vae
2 changes: 1 addition & 1 deletion cfgs/infer/text2img_sdxl.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_base_: [cfgs/infer/text2img.yaml]
_base_: [ cfgs/infer/text2img.yaml ]

emb_dir: embs_sdxl

Expand Down
25 changes: 16 additions & 9 deletions cfgs/train/examples/lora_anime_character.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ model:
pretrained_model_name_or_path: 'deepghs/animefull-latest'
clip_skip: 1

train:
train_steps: 1000
save_step: 100

scheduler:
num_training_steps: ${train.train_steps}

character_name: surtr_arknights
dataset_dir: '/root/autodl-tmp/dataset/surtr_3'
# if exp_dir is not set, a random time-based directory will be used
Expand All @@ -16,7 +23,7 @@ text_encoder_rank: 4
tokenizer_pt:
emb_dir: 'embs/' #自定义word目录
replace: False #训练后是否替换原有word
train:
train:
- name: ${character_name}
lr: 0.003

Expand Down Expand Up @@ -49,16 +56,16 @@ data:
pt1: ${character_name}

# support images with any size, not recommended for anime training
# bucket:
# _target_: hcpdiff.data.bucket.RatioBucket.from_files # aspect ratio bucket
# target_area: ${times:512,512}
# num_bucket: 5
bucket:
_target_: hcpdiff.data.bucket.RatioBucket.from_files # aspect ratio bucket
target_area: ${hcp.eval:"512*512"}
num_bucket: 5

# all images must have the same size, such as 512x704
bucket:
_target_: hcpdiff.data.bucket.SizeBucket.from_files # aspect ratio bucket
target_area: ---
num_bucket: 1
# bucket:
# _target_: hcpdiff.data.bucket.SizeBucket.from_files # aspect ratio bucket
# target_area: ---
# num_bucket: 1

logger:
- _target_: hcpdiff.loggers.CLILogger
Expand Down
124 changes: 124 additions & 0 deletions cfgs/train/examples/lora_anime_character_reg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
_base_:
- cfgs/train/examples/lora_conventional.yaml
- cfgs/train/dataset/regularization_dataset.yaml

model:
pretrained_model_name_or_path: 'deepghs/animefull-latest'
clip_skip: 1

train:
train_steps: 1000
save_step: 100

scheduler:
num_training_steps: ${train.train_steps}

character_name: surtr_arknights
dataset_dir: '/root/autodl-tmp/dataset/surtr_3'
reg_dataset_dir: '/root/autodl-tmp/reg_dataset'
# if exp_dir is not set, a random time-based directory will be used
# exp_dir: 'exps/surtr'

tag_dropout: 0.3

unet_rank: 8
text_encoder_rank: 4

tokenizer_pt:
emb_dir: 'embs/' #自定义word目录
replace: False #训练后是否替换原有word
train:
- name: ${character_name}
lr: 0.003

lora_unet:
- lr: 1e-4
rank: ${unet_rank}
layers:
- 're:.*\.attn.?$'
- 're:.*\.ff$'

lora_text_encoder:
- lr: 1e-5
rank: ${text_encoder_rank}
layers:
- 're:.*self_attn$'
- 're:.*mlp$'

data:
dataset1:
batch_size: 4
cache_latents: True

source:
data_source1:
img_root: ${dataset_dir}
prompt_template: 'prompt_tuning_template/object_caption.txt'
caption_file: ${dataset_dir} # path to image captions (file_words)

word_names:
pt1: ${character_name}

text_transforms:
_target_: torchvision.transforms.Compose
transforms:
- _target_: hcpdiff.utils.caption_tools.TagShuffle
- _target_: hcpdiff.utils.caption_tools.TagDropout
p: ${tag_dropout}
- _target_: hcpdiff.utils.caption_tools.TemplateFill
word_names: ${....word_names}

# support images with any size, not recommended for anime training
# bucket:
# _target_: hcpdiff.data.bucket.RatioSizeBucket.from_files # aspect ratio bucket
# target_area: ---
# max_area: ${hcp.eval:"768*768"}
# num_bucket: 10
bucket:
_target_: hcpdiff.data.bucket.RatioBucket.from_files # aspect ratio bucket
target_area: ${hcp.eval:"512*512"}
num_bucket: 5

dataset_class:
batch_size: 1
cache_latents: True
loss_weight: 1.0

source:
data_source1:
img_root: ${reg_dataset_dir}
prompt_template: 'prompt_tuning_template/object_caption.txt'
caption_file: ${reg_dataset_dir}

word_names:
pt1: ''

text_transforms:
_target_: torchvision.transforms.Compose
transforms:
- _target_: hcpdiff.utils.caption_tools.TagShuffle
- _target_: hcpdiff.utils.caption_tools.TagDropout
p: ${tag_dropout}
- _target_: hcpdiff.utils.caption_tools.TemplateFill
word_names: ${....word_names}

bucket:
_target_: hcpdiff.data.bucket.RatioBucket.from_files # aspect ratio bucket
target_area: ${hcp.eval:"512*512"}
num_bucket: 20

logger:
- _target_: hcpdiff.loggers.CLILogger
_partial_: True
out_path: 'train.log'
log_step: 20
- _target_: hcpdiff.loggers.TBLogger
_partial_: True
out_path: 'tblog/'
log_step: 5
# - _target_: hcpdiff.loggers.WanDBLogger
# _partial_: True
# out_path: null
# log_step: 5


122 changes: 122 additions & 0 deletions cfgs/train/examples/lora_anime_character_reg_v1.5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
_base_:
- cfgs/train/examples/lora_conventional.yaml
- cfgs/train/dataset/regularization_dataset.yaml

model:
pretrained_model_name_or_path: 'deepghs/animefull-latest'
clip_skip: 1

train:
train_steps: 10000
save_step: 200
scheduler:
num_training_steps: ${train.train_steps}

character_name: tohsaka_rin_fatestaynightufotable
# if exp_dir is not set, a random time-based directory will be used
exp_dir: 'exps/tohsaka_rin_t4_r1_w1_p0.3_initc_dunet0.01_note_720br'

dataset:
dir: '/nfs3/lora_datasets/tohsaka_rin_fatestaynightufotable'
bs: 4
resolution: 720
num_bucket: 5
reg_dataset:
dir: '/nfs3/lora_datasets/reg_all'
cache: '/nfs3/lora_datasets/reg_all.bin'
bs: 1
loss_weight: 1.0
resolution: 720
num_bucket: 20

tag_dropout: 0.2
pt:
emb_dir: 'embs/'
lr: 0.03
unet_:
lr: 1e-4
rank: 0.01

tokenizer_pt:
emb_dir: ${pt.emb_dir}
replace: False
train:
- name: ${character_name}
lr: ${pt.lr}

lora_unet:
- lr: ${unet_.lr}
rank: ${unet_.rank}
layers:
- 're:.*\.attn.?$'
- 're:.*\.ff$'
lora_text_encoder: []

data:
dataset1:
batch_size: ${dataset.bs}
cache_latents: True

source:
data_source1:
img_root: ${dataset.dir}
prompt_template: 'prompt_tuning_template/object_caption.txt'
caption_file: ${dataset.dir} # path to image captions (file_words)

word_names:
pt1: ${character_name}

text_transforms:
_target_: torchvision.transforms.Compose
transforms:
- _target_: hcpdiff.utils.caption_tools.TagShuffle
- _target_: hcpdiff.utils.caption_tools.TagDropout
p: ${tag_dropout}
- _target_: hcpdiff.utils.caption_tools.TemplateFill
word_names: ${....word_names}

bucket:
_target_: hcpdiff.data.bucket.RatioBucket.from_files # aspect ratio bucket
target_area: ${hcp.eval:"${dataset.resolution}*${dataset.resolution}"}
num_bucket: ${dataset.num_bucket}

dataset_class:
batch_size: ${reg_dataset.bs}
cache_latents: True
loss_weight: ${reg_dataset.loss_weight}
cache_path: ${reg_dataset.cache}

source:
data_source1:
img_root: ${reg_dataset.dir}
prompt_template: 'prompt_tuning_template/object_caption.txt'
caption_file: ${reg_dataset.dir}

word_names:
pt1: ''

text_transforms:
_target_: torchvision.transforms.Compose
transforms:
- _target_: hcpdiff.utils.caption_tools.TagShuffle
- _target_: hcpdiff.utils.caption_tools.TagDropout
p: ${tag_dropout}
- _target_: hcpdiff.utils.caption_tools.TemplateFill
word_names: ${....word_names}

bucket:
_target_: hcpdiff.data.bucket.RatioBucket.from_files # aspect ratio bucket
target_area: ${hcp.eval:"${reg_dataset.resolution}*${reg_dataset.resolution}"}
num_bucket: ${reg_dataset.num_bucket}

logger:
- _target_: hcpdiff.loggers.CLILogger
_partial_: True
out_path: 'train.log'
log_step: 20
- _target_: hcpdiff.loggers.TBLogger
_partial_: True
out_path: 'tblog/'
log_step: 5


Loading