From b6dc07235bb040436f7acb64f32e43cbe4d9043f Mon Sep 17 00:00:00 2001 From: Crosstyan Date: Fri, 28 Oct 2022 18:56:53 +0800 Subject: [PATCH] file structure --- .gitmodules | 6 ++++++ back.ps1 | 4 ++-- convert.ps1 | 11 ++--------- models/put_ckpt_and_vae_here.txt | 0 repos/diffusers | 1 + repos/xformers | 1 + train.ps1 | 33 ++++++++++++-------------------- 7 files changed, 24 insertions(+), 32 deletions(-) create mode 100644 .gitmodules create mode 100644 models/put_ckpt_and_vae_here.txt create mode 160000 repos/diffusers create mode 160000 repos/xformers diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5845f8a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "repos/diffusers"] + path = repos/diffusers + url = https://github.com/CCRcmcpe/diffusers +[submodule "repos/xformers"] + path = repos/xformers + url = https://github.com/facebookresearch/xformers diff --git a/back.ps1 b/back.ps1 index 5aa988a..7b6c86f 100644 --- a/back.ps1 +++ b/back.ps1 @@ -4,7 +4,7 @@ param( [string]$step ) -$BACK_CONVERTER = "repos/diffusers/scripts/convert_diffusers_to_original_stable_diffusion.py" +$BackConverter = "repos/diffusers/scripts/convert_diffusers_to_original_stable_diffusion.py" $AutoDLTmp = "/root/autodl-tmp" $OutPath = "$AutoDLTmp/output" # no slash at the end @@ -14,7 +14,7 @@ $ModelPath = Join-Path $OutPath $step $CheckpointPath = Join-Path $ModelPath "model.ckpt" # unet_half could reduce the size of the model -python $BACK_CONVERTER --model_path $ModelPath ` +python $BackConverter --model_path $ModelPath ` --checkpoint_path $CheckpointPath ` --unet_half diff --git a/convert.ps1 b/convert.ps1 index 06442cc..23fae5e 100644 --- a/convert.ps1 +++ b/convert.ps1 @@ -1,17 +1,10 @@ -$TRAINER = "repos/diffusers/examples/dreambooth/train_dreambooth.py" -$CONVERTER = "repos/diffusers/scripts/convert_original_stable_diffusion_to_diffusers.py" -$BACK_CONVERTER = "repos/diffusers/scripts/convert_diffusers_to_original_stable_diffusion.py" +$Converter = "repos/diffusers/scripts/convert_original_stable_diffusion_to_diffusers.py" # Download the model # https://pub-2fdef7a2969f43289c42ac5ae3412fd4.r2.dev/animefull-pruned.tar # https://pub-2fdef7a2969f43289c42ac5ae3412fd4.r2.dev/animevae.pt # tar -cf animefull-pruned.tar -# models/ -# |-- animevae.pt -# |-- config.yaml // the config file comes with the model -# `-- model.ckpt - $ModelDir = "models" $CheckpointPath = Join-Path $ModelDir "model.ckpt" $VaePath = Join-Path $ModelDir "animevae.pt" @@ -21,7 +14,7 @@ $ModelName = "animefull-pruned" $AutoDLTmp = "/root/autodl-tmp" $DumpPath = Join-Path $AutoDLTmp $ModelName -python $CONVERTER --checkpoint_path $CheckpointPath ` +python $Converter --checkpoint_path $CheckpointPath ` --original_config_file $ConfPath ` --vae_path $VaePath ` --dump_path $DumpPath ` diff --git a/models/put_ckpt_and_vae_here.txt b/models/put_ckpt_and_vae_here.txt new file mode 100644 index 0000000..e69de29 diff --git a/repos/diffusers b/repos/diffusers new file mode 160000 index 0000000..47ce949 --- /dev/null +++ b/repos/diffusers @@ -0,0 +1 @@ +Subproject commit 47ce949bfa04fae0e64596aff6944bbd57330151 diff --git a/repos/xformers b/repos/xformers new file mode 160000 index 0000000..e23b369 --- /dev/null +++ b/repos/xformers @@ -0,0 +1 @@ +Subproject commit e23b369c094685bd42e11928649cc03b93b768d5 diff --git a/train.ps1 b/train.ps1 index f354f86..baef846 100644 --- a/train.ps1 +++ b/train.ps1 @@ -1,17 +1,4 @@ -$TRAINER = "repos/diffusers/examples/dreambooth/train_dreambooth.py" -$CONVERTER = "repos/diffusers/scripts/convert_original_stable_diffusion_to_diffusers.py" -$BACK_CONVERTER = "repos/diffusers/scripts/convert_diffusers_to_original_stable_diffusion.py" - -# Download the model -# https://pub-2fdef7a2969f43289c42ac5ae3412fd4.r2.dev/animefull-pruned.tar -# https://pub-2fdef7a2969f43289c42ac5ae3412fd4.r2.dev/animevae.pt - -# models/ -# |-- animevae.pt -# |-- config.yaml // the config file comes with the model -# `-- model.ckpt -# See `convert.ps1` for more details - +$Trainer = "repos/diffusers/examples/dreambooth/train_dreambooth.py" $AutoDLTmp = "/root/autodl-tmp" # Prompt describing the subject, like subject's name. @@ -28,25 +15,29 @@ $TrainBatchSize = 1 # Regularization set # A more general prompt describing the subject, for generating regularization # image set. -$ClassPrompt = "masterpiece, best quality, 1girl" +$ClassPrompt = "1girl" $ClassNegativePrompt = "lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry" # Regularization set path. $ClassDir = "${AutoDLTmp}/content/class-images" # Previewing # Prompt for saving samples. -$SaveSamplePrompt = "masterpiece, best quality, sks 1girl, looking at viewer" +$SaveSamplePrompt = "sks 1girl standing looking at viewer, cowboy shot" $SaveSampleNegative = "lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry" + +# TODO: detect if the model exists +# Remind the user to excecute `convert.ps1` if the model is not existing. + # Model path $ModelName = "animefull-pruned" # I will dump to auto-tmp to save space of system disk -$ModelPath = "${AutoDLTmp}/${ModelName}" -$VaePath = "${ModelPath}/vae" -$OutPath = "${AutoDLTmp}/output" +$ModelPath = Join-Path $AutoDLTmp $ModelName +$VaePath = Join-Path $ModelPath "vae" +$OutPath = Join-Path $AutoDLTmp "output" mkdir -p $OutPath -accelerate launch $TRAINER ` +accelerate launch $Trainer ` --instance_data_dir $InstanceDir ` --instance_prompt $InstancePrompt ` --pretrained_model_name_or_path $ModelPath ` @@ -75,6 +66,6 @@ accelerate launch $TRAINER ` --save_unet_half ` --mixed_precision="fp16" -# TODO: write a script to inference images with parameters +# TODO: write a script to inference images with parameters like json? # don't care about inference. I would do it some where else. # see `back.ps1`