Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
Created using Colaboratory
Browse files Browse the repository at this point in the history
  • Loading branch information
Linaqruf committed Dec 4, 2022
1 parent 5938fc5 commit 29a1e54
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions kohya-trainer-resume.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
" \"diffusers_fine_tuning_v2\", \\\n",
" \"diffusers_fine_tuning_v3\", \\\n",
" \"diffusers_fine_tuning_v4\"]\n",
"version = \"diffusers_fine_tuning_v4\" #@param [\"diffusers_fine_tuning_v1\",\"diffusers_fine_tuning_v2\",\"diffusers_fine_tuning_v3\",\"diffusers_fine_tuning_v4\"]\n",
"version = \"diffusers_fine_tuning_v3\" #@param [\"diffusers_fine_tuning_v1\",\"diffusers_fine_tuning_v2\",\"diffusers_fine_tuning_v3\",\"diffusers_fine_tuning_v4\"]\n",
"\n",
"customVersion.append((versionDir[versionList.index(version)]))\n",
"\n",
Expand Down Expand Up @@ -311,12 +311,12 @@
" \"Stable-Diffusion-v1-4\", \\\n",
" \"Stable-Diffusion-v1-5-pruned-emaonly\" \\\n",
" \"Waifu-Diffusion-v1-3-fp32\"]\n",
"modelName = \"Anything-V3.0-pruned\" #@param [\"\", \"Animefull-final-pruned\", \"Animesfw-final-pruned\", \"Anything-V3.0-pruned-fp16\", \"Anything-V3.0-pruned-fp32\", \"Anything-V3.0-pruned\", \"Stable-Diffusion-v1-4\", \"Stable-Diffusion-v1-5-pruned-emaonly\", \"Waifu-Diffusion-v1-3-fp32\"]\n",
"modelName = \"\" #@param [\"\", \"Animefull-final-pruned\", \"Animesfw-final-pruned\", \"Anything-V3.0-pruned-fp16\", \"Anything-V3.0-pruned-fp32\", \"Anything-V3.0-pruned\", \"Stable-Diffusion-v1-4\", \"Stable-Diffusion-v1-5-pruned-emaonly\", \"Waifu-Diffusion-v1-3-fp32\"]\n",
"\n",
"#@markdown ### Custom model\n",
"#@markdown The model URL should be a direct download link.\n",
"customName = \"\" #@param {'type': 'string'}\n",
"customUrl = \"\"#@param {'type': 'string'}\n",
"customName = \"herigaru5k\" #@param {'type': 'string'}\n",
"customUrl = \"https://huggingface.co/Linaqruf/herigaru/resolve/main/herigaru5k.ckpt\"#@param {'type': 'string'}\n",
"\n",
"if customName == \"\" or customUrl == \"\":\n",
" pass\n",
Expand Down Expand Up @@ -390,7 +390,7 @@
"source": [
"#@title Training begin\n",
"num_cpu_threads_per_process = 8 #@param {'type':'integer'}\n",
"pre_trained_model_path =\"/content/kohya-trainer/checkpoint/Anything-V3.0-pruned.ckpt\" #@param {'type':'string'}\n",
"pre_trained_model_path =\"/content/herigaru/herigaru10k.ckpt\" #@param {'type':'string'}\n",
"meta_lat_json_dir = \"/content/herigaru-tag/meta_lat.json\" #@param {'type':'string'}\n",
"train_data_dir = \"/content/herigaru-tag/train_data\" #@param {'type':'string'}\n",
"output_dir =\"/content/kohya-trainer/fine_tuned\" #@param {'type':'string'}\n",
Expand All @@ -415,6 +415,7 @@
" --shuffle_caption \\\n",
" --train_batch_size={train_batch_size} \\\n",
" --learning_rate={learning_rate} \\\n",
" --logging_dir=logs \\\n",
" --max_token_length={max_token_length} \\\n",
" --clip_skip={clip_skip} \\\n",
" --mixed_precision={mixed_precision} \\\n",
Expand All @@ -423,9 +424,9 @@
" --xformers \\\n",
" --gradient_checkpointing \\\n",
" --save_state \\\n",
" --resume {resume_path} \\\n",
" --gradient_accumulation_steps {gradient_accumulation_steps} \\\n",
" --save_precision={save_precision} \n"
" --gradient_accumulation_steps {gradient_accumulation_steps}\n",
" # --save_precision={save_precision}\n",
" # --resume {resume_path} \\\n"
],
"metadata": {
"id": "X_Rd3Eh07xlA",
Expand Down Expand Up @@ -495,8 +496,8 @@
"\n",
"prune = True #@param {'type':'boolean'}\n",
"\n",
"model_src = \"/content/kohya-trainer/fine_tuned/last.ckpt\" #@param {'type' : 'string'}\n",
"model_dst = \"/content/kohya-trainer/fine_tuned/last-pruned.ckpt\" #@param {'type' : 'string'}\n",
"model_src = \"/content/kohya-trainer/checkpoint/herigaru5k.ckpt\" #@param {'type' : 'string'}\n",
"model_dst = \"/content/kohya-trainer/checkpoint/herigaru5k.ckpt\" #@param {'type' : 'string'}\n",
"\n",
"if prune == True:\n",
" import os\n",
Expand All @@ -506,7 +507,7 @@
" !wget https://raw.githubusercontent.com/lopho/stable-diffusion-prune/main/prune.py\n",
"\n",
"\n",
"!python3 prune.py -p {model_src} {model_dst}\n"
"!python3 prune.py {model_src} {model_dst}\n"
],
"metadata": {
"id": "LUOG7BzQVLKp",
Expand All @@ -532,6 +533,21 @@
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"#@title Visualize loss graph (Optional)\n",
"%cd /content/kohya-trainer\n",
"%load_ext tensorboard\n",
"%tensorboard --logdir logs"
],
"metadata": {
"cellView": "form",
"id": "PeWyOG73DR4T"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
Expand Down

0 comments on commit 29a1e54

Please sign in to comment.