Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Commit

Permalink
file structure
Browse files Browse the repository at this point in the history
  • Loading branch information
crosstyan committed Oct 28, 2022
1 parent 3b25221 commit b6dc072
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 32 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions back.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
11 changes: 2 additions & 9 deletions convert.ps1
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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 `
Expand Down
Empty file.
1 change: 1 addition & 0 deletions repos/diffusers
Submodule diffusers added at 47ce94
1 change: 1 addition & 0 deletions repos/xformers
Submodule xformers added at e23b36
33 changes: 12 additions & 21 deletions train.ps1
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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 `
Expand Down Expand Up @@ -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`

0 comments on commit b6dc072

Please sign in to comment.